public ActionResult Create(StreamingSettingViewModel model) { if (ModelState.IsValid) { string url = Url.Action("Index", "IpStreamingSetting"); this.pointsDbEntity.StreamingSettings.Add(model); this.pointsDbEntity.OperationIOs.Add( new OperationIOViewModel { ExecutedAction = string.Format(@"新增串流設定 : {0}", model.ChannelName), AuditDate = DateTime.Now, Module = "串流設定", Role = "admin" }); this.pointsDbEntity.SaveChanges(); return Json(new { success = true, url = url }); } else { var message = string.Join(" | ", ModelState.Values .SelectMany(a => a.Errors) .Select(b => b.ErrorMessage)); return Json(new { success = false, errormsg = message }); } }
public ActionResult Edit(StreamingSettingViewModel model) { if (ModelState.IsValid) { this.pointsDbEntity.Entry(model).State = System.Data.Entity.EntityState.Modified; this.pointsDbEntity.OperationIOs.Add( new OperationIOViewModel { ExecutedAction = string.Format(@"修改串流設定 : {0}", model.ChannelName), AuditDate = DateTime.Now, Module = "串流設定", Role = "admin" }); this.pointsDbEntity.SaveChanges(); return Json(new { success = true }); } else { var message = string.Join(" | ", ModelState.Values .SelectMany(a => a.Errors) .Select(b => b.ErrorMessage)); return Json(new { success = false, errormsg = message }); } }