public ActionResult Edit(long id, AddEditPathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(id); if (obj == null) { return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", vModel)); } obj.Name = vModel.DataObject.Name; obj.DegreesFromNorth = vModel.DataObject.DegreesFromNorth; obj.InclineGrade = vModel.DataObject.InclineGrade; obj.Origin = vModel.DataObject.Origin; obj.Destination = vModel.DataObject.Destination; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditPathwayTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { message = "Error; Edit failed."; } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
public ActionResult Add(long id, long originRoomId, long destinationRoomId, int degreesFromNorth = 0, int incline = 0) { //New room or existing room if (destinationRoomId.Equals(-1)) { IRoomTemplate origin = TemplateCache.Get <IRoomTemplate>(originRoomId); AddPathwayWithRoomTemplateViewModel vModel = new AddPathwayWithRoomTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = TemplateCache.GetAll <IRoomTemplate>(), Origin = origin, DataObject = new PathwayTemplate() { DegreesFromNorth = degreesFromNorth, InclineGrade = incline }, Destination = new RoomTemplate() { ParentLocation = origin.ParentLocation } }; vModel.Destination.ParentLocation = vModel.Origin.ParentLocation; return(View("~/Views/GameAdmin/Pathway/AddWithRoom.cshtml", "_chromelessLayout", vModel)); } else { IRoomTemplate origin = TemplateCache.Get <IRoomTemplate>(originRoomId); IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(destinationRoomId); IPathwayTemplate pathwayTemplate = TemplateCache.Get <IPathwayTemplate>(id); if (pathwayTemplate == null) { pathwayTemplate = new PathwayTemplate() { Origin = origin, Destination = destination, DegreesFromNorth = degreesFromNorth, InclineGrade = incline }; } AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = TemplateCache.GetAll <IRoomTemplate>().Where(rm => !rm.Id.Equals(originRoomId)), DataObject = pathwayTemplate }; return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", "_chromelessLayout", vModel)); } }
public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "") { AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()) }; if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(removeId); if (obj == null) { } else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemovePathway[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { } } else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(unapproveId); if (obj == null) { } else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned)) { LoggingUtility.LogAdminCommandUsage("*WEB* - UnapprovePathway[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { } } else { } return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", vModel)); }
public ActionResult Add(AddEditPathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate newObj = vModel.DataObject; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathway[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
public ActionResult Edit(long id, long originRoomId, long destinationRoomId) { string message = string.Empty; AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = TemplateCache.GetAll <IRoomTemplate>() }; PathwayTemplate obj = TemplateCache.Get <PathwayTemplate>(id); if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", "Room", new { Message = message })); } vModel.DataObject = obj; return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", "_chromelessLayout", vModel)); }