public ActionResult LodgeEdit(Lodge model) { return AddEditLodge(model); }
private ActionResult AddEditLodge(Lodge lodgeModel) { ActionResult rtn = RedirectToAction("LodgeAddEdit", lodgeModel); if (ModelState.IsValid) { if (lodgeModel.LodgeId == 0) { lodgeModel.DatabaseName = lodgeModel.LodgeName.Replace(" ", "").Replace(".", "") + ".xml"; LodgeDataXml.CreateNewLodgeXmlFile(lodgeModel.DatabaseName); } else { if ((lodgeModel.DatabaseName == "") || (!System.IO.File.Exists(Server.MapPath("\\App_Data\\") + lodgeModel.DatabaseName))) { lodgeModel.DatabaseName = lodgeModel.LodgeName.Replace(" ", "").Replace(".", "") + ".xml"; if (!System.IO.File.Exists(Server.MapPath("\\App_Data\\") + lodgeModel.DatabaseName)) { LodgeDataXml.CreateNewLodgeXmlFile(Server.MapPath("\\App_Data\\") + lodgeModel.DatabaseName); } } } lodgeModel.LodgeId = MasonMasterData.AddEditLodge(lodgeModel); if (lodgeModel.LodgeId < 1) ModelState.AddModelError("", "Failed to Add or Edit Lodge"); else { rtn = RedirectToAction("LodgeView"); if (lodgeModel.SetAsUserDatabase) { UserProfile userProfile = MasonMasterData.GetUserProfile(User.Identity.Name); userProfile.LodgeId = lodgeModel.LodgeId; if (MasonMasterData.UpdateUserProfile(userProfile) != "ok") { ModelState.AddModelError("", "Failed to update user profile."); rtn = View("LodgeAddEdit", lodgeModel); } } } } else { ViewBag.LodgeTypes = MasonMasterData.GetRefCodes("LDG"); rtn = View("LodgeAddEdit", lodgeModel); } return rtn; }
public ActionResult LodgeCreate(Lodge model) { model.LodgeId = 0; return AddEditLodge(model); }