Skip to content

Commit

Permalink
New Release
Browse files Browse the repository at this point in the history
  • Loading branch information
José Luiz committed Feb 4, 2018
1 parent 885535d commit 3fd9abd
Show file tree
Hide file tree
Showing 35 changed files with 792 additions and 5 deletions.
5 changes: 0 additions & 5 deletions Smart.Data/Repository/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ public void Add(T entity)

_entity.Add(entity);
this._context.SaveChanges();




}

Expand Down Expand Up @@ -124,8 +121,6 @@ public async Task<T> UpdateAsync(T entity)
_context. Entry(entity).CurrentValues.SetValues(entity);
await _context.SaveChangesAsync();
return entity;


}

public async Task<int> DeleteAsync(T entity)
Expand Down
146 changes: 146 additions & 0 deletions SmartAdmin/Controllers/CitiesController.cs
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
}

}

7 changes: 7 additions & 0 deletions SmartAdmin/Data/ContextOnlyGClasse.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -17,5 +19,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{

}

public DbSet<Smart.Core.Domain.Addresss.City> City { get; set; }

public DbSet<Smart.Core.Domain.Goals.Goal> Goal { get; set; }

}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
90 changes: 90 additions & 0 deletions SmartAdmin/Views/Cities/Add.cshtml
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>
90 changes: 90 additions & 0 deletions SmartAdmin/Views/Cities/Create.cshtml
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>

0 comments on commit 3fd9abd

Please sign in to comment.