public async Task<ActionResult> Create(CultureTextCreateModel model) { var db = MaintDbContext; CultureText cultureText= new CultureText(); if (!TryUpdateModel(cultureText, model)) { return Template(model.CreateTemplate(ControllerContext)); } var name = model.Name; if (await db.CultureTexts.AnyAsync(x => x.Name == name)) { var errorMessage = string.Format(MaintCultureTextResources.ValidationDumplicate, MaintCultureTextResources.CultureTextName, name); ModelState.AddModelError("Name", string.Format(errorMessage, name)); return Template(model.CreateTemplate(ControllerContext)); } var culture = db.Cultures.FirstOrDefault(x => x.CultureId == model.CultureId && x.IsEnabled); if (culture == null) { return HttpNotFound(); } db.CultureTexts.Add(cultureText); await db.SaveChangesAsync(); await SetFlashAsync(new FlashMessage { Text = MaintCultureTextResources.SuccessToSave, MessageType = FlashMessageType.Success, }); _maintDomainService.ClearCultureTextsCache(); return Create( ); }
public ActionResult Create(int cultureId = 0) { var model = new CultureTextCreateModel(); model.CultureId = cultureId; return Template(model.CreateTemplate(ControllerContext)); }