public async Task<ActionResult> Create(CultureCreateModel model) { var entity = new Culture(); if (!TryUpdateModel(entity, model)) { return Template(model.CreateTemplate(ControllerContext)); } var db = MaintDbContext; var name = model.Name.Trim(); ; if (db.Cultures.Any(x => x.Name == name)) { var errorMessage = string.Format(MaintCultureTextResources.ValidationDumplicate, MaintCultureTextResources.CultureName, name); ModelState.AddModelError("Name", string.Format(errorMessage, name)); return Template(model.CreateTemplate(ControllerContext)); } db.Cultures.Add(entity); await db.SaveChangesAsync(); await SetFlashAsync(new FlashMessage { Text = MaintCultureTextResources.SuccessToSave, MessageType = FlashMessageType.Success, }); return Create( ); }
public ActionResult Create() { var model = new CultureCreateModel(); return Template(model.CreateTemplate(ControllerContext)); }