public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(RedirectToPage("/Scripts/ScriptVoiceEdit", new { id = Scripts.MessageTypeId })); //return Page(); } _context.Attach(Scripts).State = EntityState.Modified; foreach (var item in Scripts.ScriptSchedules) { _context.Attach(item).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScriptsExists(Scripts.ScriptId)) { return(NotFound()); } else { throw; } } int Customerid = HttpContext.Session.GetInt32("CustomerID").Value; return(RedirectToPage("/MessageTypes/MessageTypeIndex", new { customerid = Customerid })); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(MessageTypes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MessageTypesExists(MessageTypes.MessageTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Scripts.Update(Scripts); string[] newtags = Scripts.MessageScript.Split("["); HashSet <string> NewTagSet = new HashSet <string>(); List <Models.ScriptTags> OriginalTags = _context.ScriptTags.Where(st => st.ScriptId == Scripts.ScriptId).ToList(); foreach (var item in newtags) { int p = item.IndexOf("]"); if (p > 0) { NewTagSet.Add(item.Substring(0, p)); } } List <Models.ScriptTags> NewTags = new List <Models.ScriptTags>(); foreach (var item in NewTagSet) { Models.ScriptTags originaltag = OriginalTags.Where(ot => ot.TagName == item.ToString()).FirstOrDefault(); if (originaltag == null) //new tag { NewTags.Add(new Models.ScriptTags { ScriptId = Scripts.ScriptId, TagName = item, DataTypeCode = (item.ToUpper().Contains("DATE") ? "D" : item.ToUpper().Contains("TIME") ? "T" : "") }); } } _context.ScriptTags.AddRange(NewTags); List <Models.ScriptTags> RemoveTags = new List <Models.ScriptTags>(); foreach (var item in OriginalTags) { if (!NewTagSet.Contains(item.TagName)) { RemoveTags.Add(item); } } _context.ScriptTags.RemoveRange(RemoveTags); await _context.SaveChangesAsync(); return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Customers.Add(Customers); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } foreach (var item in ScriptSchedules) { _context.ScriptSchedules.Update(item); } await _context.SaveChangesAsync(); return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } MessageTypes = await _context.MessageTypes.FindAsync(id); if (MessageTypes != null) { _context.MessageTypes.Remove(MessageTypes); await _context.SaveChangesAsync(); } return(RedirectToPage("./MessageTypeIndex")); }