-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
José Luiz
committed
Feb 4, 2018
1 parent
885535d
commit 3fd9abd
Showing
35 changed files
with
792 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<City> _cityServices; | ||
private readonly IServices<StateProvince> _stateProvinceServices; | ||
#endregion | ||
|
||
|
||
#region ctor | ||
public CitiesController( | ||
IServices<StateProvince> stateProvinceServices, | ||
IServices<City> cityServices, | ||
IUser currentUser, | ||
IServices<UserSetting> 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 | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@model Smart.Core.Domain.Addresss.City | ||
|
||
@{ | ||
Layout = null; | ||
} | ||
|
||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Add</title> | ||
</head> | ||
<body> | ||
|
||
<form asp-action="Add"> | ||
<div class="form-horizontal"> | ||
<h4>City</h4> | ||
<hr /> | ||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> | ||
<div> teste </div> | ||
<div class="form-group"> | ||
<label asp-for="Name" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="Name" class="form-control" /> | ||
<span asp-validation-for="Name" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="MiddleName" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="MiddleName" class="form-control" /> | ||
<span asp-validation-for="MiddleName" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="SpecialCodeRegion" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="SpecialCodeRegion" class="form-control" /> | ||
<span asp-validation-for="SpecialCodeRegion" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="StateProvinceId" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<select asp-for="StateProvinceId" class ="form-control" asp-items="ViewBag.StateProvinceId"></select> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="CreateDate" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="CreateDate" class="form-control" /> | ||
<span asp-validation-for="CreateDate" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="ModifiedDate" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="ModifiedDate" class="form-control" /> | ||
<span asp-validation-for="ModifiedDate" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="Rowguid" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="Rowguid" class="form-control" /> | ||
<span asp-validation-for="Rowguid" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="BusinessEntityId" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="BusinessEntityId" class="form-control" /> | ||
<span asp-validation-for="BusinessEntityId" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-md-offset-2 col-md-10"> | ||
<input type="submit" value="Create" class="btn btn-default" /> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
<div> | ||
<a asp-action="Index">Back to List</a> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@model Smart.Core.Domain.Addresss.City | ||
|
||
@{ | ||
Layout = null; | ||
} | ||
|
||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>Create</title> | ||
</head> | ||
<body> | ||
|
||
<form asp-action="Create"> | ||
<div class="form-horizontal"> | ||
<h4>City</h4> | ||
<hr /> | ||
<div asp-validation-summary="ModelOnly" class="text-danger"></div> | ||
<div> teste </div> | ||
<div class="form-group"> | ||
<label asp-for="Name" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="Name" class="form-control" /> | ||
<span asp-validation-for="Name" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="MiddleName" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="MiddleName" class="form-control" /> | ||
<span asp-validation-for="MiddleName" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="SpecialCodeRegion" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="SpecialCodeRegion" class="form-control" /> | ||
<span asp-validation-for="SpecialCodeRegion" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="StateProvinceId" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<select asp-for="StateProvinceId" class ="form-control" asp-items="ViewBag.StateProvinceId"></select> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="CreateDate" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="CreateDate" class="form-control" /> | ||
<span asp-validation-for="CreateDate" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="ModifiedDate" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="ModifiedDate" class="form-control" /> | ||
<span asp-validation-for="ModifiedDate" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="Rowguid" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="Rowguid" class="form-control" /> | ||
<span asp-validation-for="Rowguid" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label asp-for="BusinessEntityId" class="col-md-2 control-label"></label> | ||
<div class="col-md-10"> | ||
<input asp-for="BusinessEntityId" class="form-control" /> | ||
<span asp-validation-for="BusinessEntityId" class="text-danger"></span> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-md-offset-2 col-md-10"> | ||
<input type="submit" value="Create" class="btn btn-default" /> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
<div> | ||
<a asp-action="Index">Back to List</a> | ||
</div> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.