public Culture Map(CreateOrEditViewModel createOrEdit) { Culture culture = new Culture(); if (createOrEdit.Id != null) culture = this.handler.Storage.GetRepository<ICultureRepository>().WithKey((int)createOrEdit.Id); culture.Code = createOrEdit.Code; culture.Name = createOrEdit.Name; return culture; }
public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit) { if (this.ModelState.IsValid) { Culture culture = new CreateOrEditViewModelMapper(this).Map(createOrEdit); if (createOrEdit.Id == null) this.Storage.GetRepository<ICultureRepository>().Create(culture); else this.Storage.GetRepository<ICultureRepository>().Edit(culture); this.Storage.Save(); return this.Redirect(this.Request.CombineUrl("/backend/cultures")); } return this.CreateRedirectToSelfResult(); }