public async Task <IActionResult> Edit(int id, LabelFormModel model) { var labelExists = await this.labelService.ExistsAsync(id); if (!labelExists) { this.TempData.AddErrorMessage(WebAdminConstants.LabelNotFoundMsg); return(RedirectToAction(nameof(Index))); } if (!this.ModelState.IsValid) { return(this.View(model)); } await this.labelService.UpdateAsync( id, model.Name, model.Description); this.TempData.AddSuccessMessage(string.Format( WebAdminConstants.LabelUpdatedMsg, model.Name.ToStrongHtml())); return(this.RedirectToAction(nameof(Index))); }
public ActionResult Add(int sourceType, int sourceId, LabelFormModel model) { var label = LabelService.LabelAdd((SourceType)sourceType, sourceId, model.Name); if (label.IsValid) { model.IsNew = true; } this.Map(label, model, false); return(PartialView("LabelUserControl", model)); }
public ActionResult Add(int sourceType, int sourceId, LabelFormModel model) { var label = LabelService.LabelAdd((SourceType)sourceType, sourceId, model.Name); if (label.IsValid) { model.IsNew = true; } this.Map(label, model, false); return PartialView("LabelUserControl", model); }
public async Task <IActionResult> Create(LabelFormModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } await this.labelService.CreateAsync( model.Name, model.Description); this.TempData.AddSuccessMessage(string.Format( WebAdminConstants.LabelCreatedMsg, model.Name.ToStrongHtml())); return(this.RedirectToAction(nameof(Index))); }
public LabelFormModel Map(Label label, LabelFormModel model, bool ignoreBrokenRules) { Csla.Data.DataMapper.Map(label, model, true); model.Tab = "Task"; model.IsNew = label.IsNew; model.IsValid = label.IsValid; if (!ignoreBrokenRules) { foreach (var brokenRule in label.BrokenRulesCollection) { this.ModelState.AddModelError(string.Empty, brokenRule.Description); } } return(model); }
public LabelFormModel Map(Label label, LabelFormModel model, bool ignoreBrokenRules) { Csla.Data.DataMapper.Map(label, model, true); model.Tab = "Task"; model.IsNew = label.IsNew; model.IsValid = label.IsValid; if (!ignoreBrokenRules) { foreach (var brokenRule in label.BrokenRulesCollection) { this.ModelState.AddModelError(string.Empty, brokenRule.Description); } } return model; }