public ActionResult Details(UserModel model) { if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { var x = GetUser(model.Email); if (x != null) { model = new UserModel { FirstName = x.FirstName, LastName = x.LastName, IsAdmin = x.IsAdmin, Email = x.Email, IsSuperAdmin = x.IsSuperAdmin, Password = x.Password }; return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
// GET: User public ActionResult List() { if (BaseUser != null && !BaseUser.IsInRole("Default") && !BaseUser.IsInRole("Admin")) { var d = GetAllUsers(); var model = new List <UserModel>(); foreach (var x in d) { model.Add(new UserModel { FirstName = x.FirstName, LastName = x.LastName, IsAdmin = x.IsAdmin, Email = x.Email, IsSuperAdmin = x.IsSuperAdmin, Password = x.Password }); } if (model.Count > 0) { return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Details(string email) { if (email.Contains("%40")) { email = email.Replace("%40", "@"); } if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { var x = GetUser(email); var model = new UserModel { FirstName = x.FirstName, LastName = x.LastName, IsAdmin = x.IsAdmin, Email = x.Email, IsSuperAdmin = x.IsSuperAdmin, Password = x.Password }; if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { return(View("~/views/user/Details.cshtml", model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Edit(Device device) { try { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { // TODO: Add update logic here //int iD, string name, bool roomAsigned, int roomNr, DateTime reportedOn, DateTime assignedOn var x = DataAccess.EditItem(device.DeviceID, device.Name, device.RoomAsigned, device.RoomNr, device.ReportedOn, device.AssignedOn); return(RedirectToAction("List", "Device")); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } } catch { return(View()); } }
public ActionResult Edit(int did) { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { var x = DataAccess.LoadItemById(did); var model = new Device() { DeviceID = x.DeviceID, Name = x.Name, AssignedOn = x.AssignedOn, ReportedOn = x.ReportedOn, RoomAsigned = x.RoomAsigned, RoomNr = x.RoomNr }; return(View("~/views/device/Edit.cshtml", model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
//[Authorize(Roles = "Admin,SuperAdmin")] // GET: Device/Details/5 public ActionResult Details(int did) { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { var d = DataAccess.LoadItemById(did); var model = new Device { DeviceID = d.DeviceID, Name = d.Name, RoomAsigned = d.RoomAsigned, AssignedOn = d.AssignedOn, ReportedOn = d.ReportedOn, RoomNr = d.RoomNr }; return(View("~/views/device/_details.cshtml", model)); } return(View("~/views/shared/Error.cshtml")); } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Edit(UserModel model) { if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { //update fehlt return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Delete() { var model = new UserModel(); if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Index() { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { var model = new List <Device>(); var x = DataAccess.LoadItems(); foreach (var d in x) { model.Add(new Device { DeviceID = d.DeviceID, Name = d.Name, RoomAsigned = d.RoomAsigned, AssignedOn = d.AssignedOn, ReportedOn = d.ReportedOn, RoomNr = d.RoomNr }); } if (model.Count > 0) { return(View("~/views/device/_list.cshtml", model)); } else { return(View("~/views/auth/_login.cshtml")); } } if (BaseUser.IsInRole("Default")) { return(View("~/views/shared/Error.cshtml")); } else { return(View("~/views/auth/_login.cshtml")); } } else { return(View("~/views/auth/_login.cshtml")); } }
public ActionResult List() { if (BaseUser != null) { if (BaseUser.IsInRole("Admin") || BaseUser.IsInRole("SuperAdmin")) { var model = new List <Device>(); //model.Add(new Device { ID=1,Name="ESP1",RoomAsigned=true,RoomNr=367,AssignedOn=DateTime.Now.AddDays(-6.0),ReportedOn=DateTime.Now }); //model.Add(new Device { ID=2,Name="ESP2",RoomAsigned=true,RoomNr=368, AssignedOn = DateTime.Now.AddDays(-3.0), ReportedOn = DateTime.Now.AddDays(-1.0) }); //model.Add(new Device { ID=3,Name="ESP3",RoomAsigned=false,RoomNr=365, AssignedOn = DateTime.Now.AddDays(-12.0), ReportedOn = DateTime.Now }); var x = DataAccess.LoadItems(); foreach (var d in x) { model.Add(new Device { DeviceID = d.DeviceID, Name = d.Name, RoomAsigned = d.RoomAsigned, AssignedOn = d.AssignedOn, ReportedOn = d.ReportedOn, RoomNr = d.RoomNr }); } if (model.Count > 0) { return(View("~/views/device/_list.cshtml", model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Delete(UserModel model) { if (BaseUser != null && BaseUser.IsInRole("SuperAdmin")) { var x = DeleteUser(model.Email, model.FirstName, model.LastName); if (x) { return(View(model)); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }
public ActionResult Create(UserModel model) { if (BaseUser.IsInRole("SuperAdmin")) { var ePass = Encrypt(model.Password); var x = CreateUser(model.FirstName, model.LastName, model.IsAdmin, model.IsSuperAdmin, model.Email, ePass); if (x) { return(View()); } else { return(View("~/views/shared/Error.cshtml")); } } else { return(View("~/views/shared/Error.cshtml")); } }