public ActionResult EditOperator(int? id) { var operatorInfo = new OperatorInfo(); if (id != null) operatorInfo = new OperatorInfoManager().GetOperatorInfo((int)id); return View(operatorInfo); }
public OperatorInfo UpdateOperatorInfo(OperatorInfo update) { var operatorInfo = new OCM.Core.Data.Operator(); if (update.ID > 1) { //existing operator operatorInfo = DataModel.Operators.FirstOrDefault(o => o.ID == update.ID); } operatorInfo.Title = update.Title; operatorInfo.WebsiteURL = update.WebsiteURL; operatorInfo.Comments = update.Comments; operatorInfo.PhonePrimaryContact = update.PhonePrimaryContact; operatorInfo.PhoneSecondaryContact = update.PhoneSecondaryContact; operatorInfo.IsPrivateIndividual = update.IsPrivateIndividual; operatorInfo.IsRestrictedEdit = update.IsRestrictedEdit; operatorInfo.BookingURL = update.BookingURL; operatorInfo.ContactEmail = update.ContactEmail; operatorInfo.FaultReportEmail = update.FaultReportEmail; if (operatorInfo.ID == 0) { //add new DataModel.Operators.Add(operatorInfo); } DataModel.SaveChanges(); update = Model.Extensions.OperatorInfo.FromDataModel(operatorInfo); CacheManager.RefreshCachedData(); return update; }
public ActionResult EditOperator(OperatorInfo operatorInfo) { if (ModelState.IsValid) { var operatorInfoManager = new OperatorInfoManager(); operatorInfo = operatorInfoManager.UpdateOperatorInfo(operatorInfo); CacheManager.RefreshCachedData(); return RedirectToAction("Operators", "Admin"); } return View(operatorInfo); }