diff --git a/Smart.Data/Repository/Repository.cs b/Smart.Data/Repository/Repository.cs index d15090b..a49df8a 100644 --- a/Smart.Data/Repository/Repository.cs +++ b/Smart.Data/Repository/Repository.cs @@ -78,9 +78,6 @@ public void Add(T entity) _entity.Add(entity); this._context.SaveChanges(); - - - } @@ -124,8 +121,6 @@ public async Task UpdateAsync(T entity) _context. Entry(entity).CurrentValues.SetValues(entity); await _context.SaveChangesAsync(); return entity; - - } public async Task DeleteAsync(T entity) diff --git a/SmartAdmin/Controllers/CitiesController.cs b/SmartAdmin/Controllers/CitiesController.cs new file mode 100644 index 0000000..876e641 --- /dev/null +++ b/SmartAdmin/Controllers/CitiesController.cs @@ -0,0 +1,146 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.EntityFrameworkCore; +using Smart.Services.Interfaces; +using Smart.Core.Domain.Identity; +using SmartAdmin.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authorization; +using System.Reflection; +using System.IO; + + +using Smart.Core.Domain.Addresss; +using SmartAdmin.Data; + +namespace SmartAdmin.Controllers +{ + + public class CitiesController : BaseController + { + + #region vars + private readonly IServices _cityServices; + private readonly IServices _stateProvinceServices; + #endregion + + + #region ctor + public CitiesController( + IServices stateProvinceServices, + IServices cityServices, + IUser currentUser, + IServices currentSetting, + IEmailSender emailSender, + ISmsSender smsSender, + IHttpContextAccessor accessor + ) : base(currentUser, currentSetting, emailSender, smsSender, accessor) + { + this._cityServices = cityServices; + this._stateProvinceServices = stateProvinceServices; + } + #endregion + + #region methods + + // GET: Cities + [Route("city-management/city-list")] + public IActionResult List(string search) + { + ViewData["search"] = search; + var data = _cityServices.Query(); + if (!string.IsNullOrEmpty(search)) + { + data = data.Where(p => + p.Name.Contains(search) + || p.MiddleName.Contains(search) + || p.SpecialCodeRegion.Contains(search) + ); + } + return View(data.ToList()); + } + + [Route("city-management/city-add")] + public IActionResult Add() + { + ViewData["StateProvinceId"] = new SelectList(_stateProvinceServices.GetAll(), "StateProvinceId", "CountryRegionCode"); + var data = new City(); + return View(data); + } + + [HttpPost, ValidateAntiForgeryToken] + [Route("city-management/city-add")] + public IActionResult Add([Bind("CityId,Name,MiddleName,SpecialCodeRegion,StateProvinceId,CreateDate,ModifiedDate,Rowguid,BusinessEntityId")] City city, bool continueAdd) + { + ViewData["StateProvinceId"] = new SelectList(_stateProvinceServices.GetAll(), "StateProvinceId", "CountryRegionCode"); + if (!ModelState.IsValid) return View(city); + _cityServices.Add(city); + return continueAdd ? RedirectToAction("Add") : RedirectToAction("List"); + } + + + [Route("city-management/city-edit/{id?}")] + public IActionResult Edit(int? id) + { + if (id == null) + { + return NotFound(); + } + var city = _cityServices.Find(id); + if (city == null) + { + return NotFound(); + } + ViewData["StateProvinceId"] = new SelectList(_stateProvinceServices.GetAll(), "StateProvinceId", "CountryRegionCode"); + return View(city); + } + + + [HttpPost, ValidateAntiForgeryToken] + [Route("city-management/city-edit/{id?}")] + public IActionResult Edit([Bind("CityId,Name,MiddleName,SpecialCodeRegion,StateProvinceId,CreateDate,ModifiedDate,Rowguid,BusinessEntityId")] City city, bool continueAdd, bool addTrash) + { + ViewData["StateProvinceId"] = new SelectList(_stateProvinceServices.GetAll(), "StateProvinceId", "CountryRegionCode"); + if (!ModelState.IsValid) return View(city); + + + + + + _cityServices.Update(city); + return continueAdd ? RedirectToAction("Edit", new { id = city.CityId }) : RedirectToAction("List"); + } + + + [Route("city-management/city-delete/{id?}")] + public IActionResult Delete(int? id) + { + if (id == null) + { + return NotFound(); + } + var city = _cityServices.Find(id); + if (city == null) + { + return NotFound(); + } + return View(city); + } + [HttpPost, ValidateAntiForgeryToken] + [Route("city-management/city-delete/{id?}")] + public IActionResult Delete(City city) + { + _cityServices.Delete(city); + return RedirectToAction("List"); + } + + #endregion + } + +} + diff --git a/SmartAdmin/Data/ContextOnlyGClasse.cs b/SmartAdmin/Data/ContextOnlyGClasse.cs index 92da809..b2db6f7 100644 --- a/SmartAdmin/Data/ContextOnlyGClasse.cs +++ b/SmartAdmin/Data/ContextOnlyGClasse.cs @@ -1,6 +1,8 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; +using Smart.Core.Domain.Addresss; +using Smart.Core.Domain.Goals; namespace SmartAdmin.Data { @@ -17,5 +19,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { } + + public DbSet City { get; set; } + + public DbSet Goal { get; set; } + } } \ No newline at end of file diff --git a/SmartAdmin/Templates/ControllerGenerator/ApiControllerWIthActions.cshtml b/SmartAdmin/TemplatesRef/ControllerGenerator/ApiControllerWIthActions.cshtml similarity index 100% rename from SmartAdmin/Templates/ControllerGenerator/ApiControllerWIthActions.cshtml rename to SmartAdmin/TemplatesRef/ControllerGenerator/ApiControllerWIthActions.cshtml diff --git a/SmartAdmin/Templates/ControllerGenerator/ApiControllerWithContext.cshtml b/SmartAdmin/TemplatesRef/ControllerGenerator/ApiControllerWithContext.cshtml similarity index 100% rename from SmartAdmin/Templates/ControllerGenerator/ApiControllerWithContext.cshtml rename to SmartAdmin/TemplatesRef/ControllerGenerator/ApiControllerWithContext.cshtml diff --git a/SmartAdmin/Templates/ControllerGenerator/ApiEmptyController.cshtml b/SmartAdmin/TemplatesRef/ControllerGenerator/ApiEmptyController.cshtml similarity index 100% rename from SmartAdmin/Templates/ControllerGenerator/ApiEmptyController.cshtml rename to SmartAdmin/TemplatesRef/ControllerGenerator/ApiEmptyController.cshtml diff --git a/SmartAdmin/Templates/ControllerGenerator/ControllerWithActions.cshtml b/SmartAdmin/TemplatesRef/ControllerGenerator/ControllerWithActions.cshtml similarity index 100% rename from SmartAdmin/Templates/ControllerGenerator/ControllerWithActions.cshtml rename to SmartAdmin/TemplatesRef/ControllerGenerator/ControllerWithActions.cshtml diff --git a/SmartAdmin/Templates/ControllerGenerator/EmptyController.cshtml b/SmartAdmin/TemplatesRef/ControllerGenerator/EmptyController.cshtml similarity index 100% rename from SmartAdmin/Templates/ControllerGenerator/EmptyController.cshtml rename to SmartAdmin/TemplatesRef/ControllerGenerator/EmptyController.cshtml diff --git a/SmartAdmin/Templates/ControllerGenerator/MvcControllerWithContext.cshtml b/SmartAdmin/TemplatesRef/ControllerGenerator/MvcControllerWithContext.cshtml similarity index 100% rename from SmartAdmin/Templates/ControllerGenerator/MvcControllerWithContext.cshtml rename to SmartAdmin/TemplatesRef/ControllerGenerator/MvcControllerWithContext.cshtml diff --git a/SmartAdmin/Templates/MvcLayout/Error.cshtml b/SmartAdmin/TemplatesRef/MvcLayout/Error.cshtml similarity index 100% rename from SmartAdmin/Templates/MvcLayout/Error.cshtml rename to SmartAdmin/TemplatesRef/MvcLayout/Error.cshtml diff --git a/SmartAdmin/Templates/MvcLayout/_Layout.cshtml b/SmartAdmin/TemplatesRef/MvcLayout/_Layout.cshtml similarity index 100% rename from SmartAdmin/Templates/MvcLayout/_Layout.cshtml rename to SmartAdmin/TemplatesRef/MvcLayout/_Layout.cshtml diff --git a/SmartAdmin/Templates/Startup/ReadMe.cshtml b/SmartAdmin/TemplatesRef/Startup/ReadMe.cshtml similarity index 100% rename from SmartAdmin/Templates/Startup/ReadMe.cshtml rename to SmartAdmin/TemplatesRef/Startup/ReadMe.cshtml diff --git a/SmartAdmin/Templates/Startup/Startup.cshtml b/SmartAdmin/TemplatesRef/Startup/Startup.cshtml similarity index 100% rename from SmartAdmin/Templates/Startup/Startup.cshtml rename to SmartAdmin/TemplatesRef/Startup/Startup.cshtml diff --git a/SmartAdmin/Templates/StaticFiles/Content/Site.css b/SmartAdmin/TemplatesRef/StaticFiles/Content/Site.css similarity index 100% rename from SmartAdmin/Templates/StaticFiles/Content/Site.css rename to SmartAdmin/TemplatesRef/StaticFiles/Content/Site.css diff --git a/SmartAdmin/Templates/StaticFiles/Content/bootstrap.css b/SmartAdmin/TemplatesRef/StaticFiles/Content/bootstrap.css similarity index 100% rename from SmartAdmin/Templates/StaticFiles/Content/bootstrap.css rename to SmartAdmin/TemplatesRef/StaticFiles/Content/bootstrap.css diff --git a/SmartAdmin/Templates/StaticFiles/Content/bootstrap.min.css b/SmartAdmin/TemplatesRef/StaticFiles/Content/bootstrap.min.css similarity index 100% rename from SmartAdmin/Templates/StaticFiles/Content/bootstrap.min.css rename to SmartAdmin/TemplatesRef/StaticFiles/Content/bootstrap.min.css diff --git a/SmartAdmin/Templates/StaticFiles/Scripts/jquery-1.10.2.min.map b/SmartAdmin/TemplatesRef/StaticFiles/Scripts/jquery-1.10.2.min.map similarity index 100% rename from SmartAdmin/Templates/StaticFiles/Scripts/jquery-1.10.2.min.map rename to SmartAdmin/TemplatesRef/StaticFiles/Scripts/jquery-1.10.2.min.map diff --git a/SmartAdmin/Templates/ViewGenerator/Add.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/Add.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/Add.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/Add.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/Create.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/Create.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/Create.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/Create.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/Delete.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/Delete.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/Delete.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/Delete.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/Details.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/Details.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/Details.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/Details.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/Edit.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/Edit.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/Edit.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/Edit.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/Empty.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/Empty.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/Empty.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/Empty.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/List.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/List.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/List.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/List.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/_CreateOrUpdate.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/_CreateOrUpdate.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/_CreateOrUpdate.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/_CreateOrUpdate.cshtml diff --git a/SmartAdmin/Templates/ViewGenerator/_ValidationScriptsPartial.cshtml b/SmartAdmin/TemplatesRef/ViewGenerator/_ValidationScriptsPartial.cshtml similarity index 100% rename from SmartAdmin/Templates/ViewGenerator/_ValidationScriptsPartial.cshtml rename to SmartAdmin/TemplatesRef/ViewGenerator/_ValidationScriptsPartial.cshtml diff --git a/SmartAdmin/Views/Cities/Add.cshtml b/SmartAdmin/Views/Cities/Add.cshtml new file mode 100644 index 0000000..8540857 --- /dev/null +++ b/SmartAdmin/Views/Cities/Add.cshtml @@ -0,0 +1,90 @@ +@model Smart.Core.Domain.Addresss.City + +@{ + Layout = null; +} + + + + + + + Add + + + +
+
+

City

+
+
+
teste
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + + + diff --git a/SmartAdmin/Views/Cities/Create.cshtml b/SmartAdmin/Views/Cities/Create.cshtml new file mode 100644 index 0000000..4c281f9 --- /dev/null +++ b/SmartAdmin/Views/Cities/Create.cshtml @@ -0,0 +1,90 @@ +@model Smart.Core.Domain.Addresss.City + +@{ + Layout = null; +} + + + + + + + Create + + + +
+
+

City

+
+
+
teste
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+ + + + + diff --git a/SmartAdmin/Views/Cities/Delete.cshtml b/SmartAdmin/Views/Cities/Delete.cshtml new file mode 100644 index 0000000..1cebce6 --- /dev/null +++ b/SmartAdmin/Views/Cities/Delete.cshtml @@ -0,0 +1,80 @@ +@model Smart.Core.Domain.Addresss.City + +@{ + Layout = null; +} + + + + + + + Delete + + + +

Are you sure you want to delete this?

+
+

City

+
+
+ +
+ @Html.DisplayNameFor(model => model.Name) +
+
+ @Html.DisplayFor(model => model.Name) +
+
+ @Html.DisplayNameFor(model => model.MiddleName) +
+
+ @Html.DisplayFor(model => model.MiddleName) +
+
+ @Html.DisplayNameFor(model => model.SpecialCodeRegion) +
+
+ @Html.DisplayFor(model => model.SpecialCodeRegion) +
+
+ @Html.DisplayNameFor(model => model.CreateDate) +
+
+ @Html.DisplayFor(model => model.CreateDate) +
+
+ @Html.DisplayNameFor(model => model.ModifiedDate) +
+
+ @Html.DisplayFor(model => model.ModifiedDate) +
+
+ @Html.DisplayNameFor(model => model.Rowguid) +
+
+ @Html.DisplayFor(model => model.Rowguid) +
+
+ @Html.DisplayNameFor(model => model.BusinessEntityId) +
+
+ @Html.DisplayFor(model => model.BusinessEntityId) +
+
+ @Html.DisplayNameFor(model => model.StateProvince) +
+
+ @Html.DisplayFor(model => model.StateProvince.CountryRegionCode) +
+
+ +
+
+ | + Back to List +
+
+
+ + diff --git a/SmartAdmin/Views/Cities/Details.cshtml b/SmartAdmin/Views/Cities/Details.cshtml new file mode 100644 index 0000000..597e883 --- /dev/null +++ b/SmartAdmin/Views/Cities/Details.cshtml @@ -0,0 +1,75 @@ +@model Smart.Core.Domain.Addresss.City + +@{ + Layout = null; +} + + + + + + + Details + + + +
+

City

+
+
+
+ @Html.DisplayNameFor(model => model.Name) +
+
+ @Html.DisplayFor(model => model.Name) +
+
+ @Html.DisplayNameFor(model => model.MiddleName) +
+
+ @Html.DisplayFor(model => model.MiddleName) +
+
+ @Html.DisplayNameFor(model => model.SpecialCodeRegion) +
+
+ @Html.DisplayFor(model => model.SpecialCodeRegion) +
+
+ @Html.DisplayNameFor(model => model.CreateDate) +
+
+ @Html.DisplayFor(model => model.CreateDate) +
+
+ @Html.DisplayNameFor(model => model.ModifiedDate) +
+
+ @Html.DisplayFor(model => model.ModifiedDate) +
+
+ @Html.DisplayNameFor(model => model.Rowguid) +
+
+ @Html.DisplayFor(model => model.Rowguid) +
+
+ @Html.DisplayNameFor(model => model.BusinessEntityId) +
+
+ @Html.DisplayFor(model => model.BusinessEntityId) +
+
+ @Html.DisplayNameFor(model => model.StateProvince) +
+
+ @Html.DisplayFor(model => model.StateProvince.CountryRegionCode) +
+
+
+ + + diff --git a/SmartAdmin/Views/Cities/Edit.cshtml b/SmartAdmin/Views/Cities/Edit.cshtml new file mode 100644 index 0000000..1d31cf3 --- /dev/null +++ b/SmartAdmin/Views/Cities/Edit.cshtml @@ -0,0 +1,34 @@ +@model Smart.Core.Domain.Addresss.City +
+

@Localizer["City"]

+

@Localizer["Definição de City"]

+
+ @{ await Html.RenderPartialAsync("_CreateOrUpdate"); } +
+
+
+
    +
  • + +
  • +
  • + +
  • +
  • + @Localizer["Voltar"] +
  • +
  • + +
  • +
+
+
+
+
+
diff --git a/SmartAdmin/Views/Cities/Index.cshtml b/SmartAdmin/Views/Cities/Index.cshtml new file mode 100644 index 0000000..7cc9f60 --- /dev/null +++ b/SmartAdmin/Views/Cities/Index.cshtml @@ -0,0 +1,79 @@ +@model IEnumerable + + + +
+
+

@Localizer["City"]

+

@Localizer["Registros Localizados:"] (@Model.Count())

+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + @foreach (var item in Model) { + + + + + + + + + + } + +
@Localizer["CityId"] @Localizer["Name"] @Localizer["MiddleName"] @Localizer["SpecialCodeRegion"] @Localizer["Rowguid"] + @Html.DisplayNameFor(model => model.StateProvince) +
+ @Html.DisplayFor(modelItem => item.CityId) + + @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.MiddleName) + + @Html.DisplayFor(modelItem => item.SpecialCodeRegion) + + @Html.DisplayFor(modelItem => item.Rowguid) + + @Html.DisplayFor(modelItem => item.StateProvince.CountryRegionCode) + + @Localizer["Editar"] +
+
+
+
+
+
+@section Scripts { + +} diff --git a/SmartAdmin/Views/Cities/List.cshtml b/SmartAdmin/Views/Cities/List.cshtml new file mode 100644 index 0000000..1ae8bee --- /dev/null +++ b/SmartAdmin/Views/Cities/List.cshtml @@ -0,0 +1,15 @@ + +@{ + Layout = null; +} + + +jose + + + + List + + + + diff --git a/SmartAdmin/Views/Goalss/List.cshtml b/SmartAdmin/Views/Goalss/List.cshtml new file mode 100644 index 0000000..54fd33f --- /dev/null +++ b/SmartAdmin/Views/Goalss/List.cshtml @@ -0,0 +1,99 @@ +@model IEnumerable + + + +
+
+

@Localizer["Goal"]

+

@Localizer["Registros Localizados:"] (@Model.Count())

+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + @foreach (var item in Model) { + + + + + + + + + + + + + + } + +
@Localizer["Id"] @Localizer["Name"] @Localizer["Period"] @Localizer["Measure"] @Localizer["Value"] @Localizer["Rowguid"] @Localizer["Active"] + @Html.DisplayNameFor(model => model.Pipeline) + + @Html.DisplayNameFor(model => model.Stage) + + @Html.DisplayNameFor(model => model.UserSetting) +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.Period) + + @Html.DisplayFor(modelItem => item.Measure) + + @Html.DisplayFor(modelItem => item.Value) + + @Html.DisplayFor(modelItem => item.Rowguid) + + @Html.DisplayFor(modelItem => item.Active) + + @Html.DisplayFor(modelItem => item.Pipeline.Name) + + @Html.DisplayFor(modelItem => item.Stage.Name) + + @Html.DisplayFor(modelItem => item.UserSetting.UserSettingId) + + @Localizer["Editar"] +
+
+
+
+
+
+@section Scripts { + +} diff --git a/SmartAdmin/Views/Goalss/_CreateOrUpdate.cshtml b/SmartAdmin/Views/Goalss/_CreateOrUpdate.cshtml new file mode 100644 index 0000000..599c6dc --- /dev/null +++ b/SmartAdmin/Views/Goalss/_CreateOrUpdate.cshtml @@ -0,0 +1,77 @@ +@model Smart.Core.Domain.Goals.Goal + + + @{ Layout = null; } + @Html.HiddenFor(a => a.Id) + @Html.HiddenFor(a => a.CreateDate) + @Html.HiddenFor(a => a.ModifiedDate) + @Html.HiddenFor(a => a.Deleted) + @Html.HiddenFor(a => a.BusinessEntityId) +
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+
+ +
+
+
+