public async Task <ActionResult> Manage(PackageRegionViewModel model, string method) { if (this.ModelState.IsValid) { var record = this.Mapper.Map <PackageRegionModel>(model); if (model.Id == 0) { record.SetAuditInfo(0); await this.region.InsertAsync(record); this.ShowMessage(Messages.SavedSuccessfully); } else { record.UpdateAuditInfo(0); await this.region.UpdateAsync(record); this.ShowMessage(Messages.UpdateSuccessfully); } if (method == "ajax") { return(this.Json(new { success = true, Name = model.Name, Id = record.Id })); } return(this.RedirectToRoute(Constants.RouteArea, new { controller = "region", action = "index", area = Constants.AreaAdmin })); } return(this.View(model)); }
public async Task <ActionResult> Manage(int id) { var model = new PackageRegionViewModel(); if (id > 0) { var record = await this.region.GetByIdAsync(id); model = this.Mapper.Map <PackageRegionViewModel>(record); } return(this.IsAjaxRequest() ? this.View("_Region", model) : this.View(model)); }