public ActionResult Save(Frycz_pcdb.user userIn) { if (!Validator.validUser(userIn)) { ModelState.AddModelError("valid", "Firstname or lastname is invalid."); return(View("EditUser", userIn)); } if (ModelState.IsValid) { if (Validator.checkExistUser(userIn)) { ModelState.AddModelError("exist", "User is already exist."); return(View("EditUser", userIn)); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { Frycz_pcdb.user user = entities.users.FirstOrDefault(u => u.iduser == userIn.iduser); user.lastname = userIn.lastname; user.firstname = userIn.firstname; Logger.logUser(user, "Edit", User); entities.SaveChanges(); return(RedirectToAction("Index", "UserDetail", user)); } } return(View("EditUser", userIn)); }
public ActionResult SaveReset(registered_user user, string password1, string password2) { if (!password1.Equals(password2)) { ModelState.AddModelError("same", "Passwords must be same."); return(View("ResetPassword", user)); } if (password1.Length < 4) { ModelState.AddModelError("same", "Minimum password length is 4 characters."); return(View("ResetPassword", user)); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { registered_user u = entities.registered_user.FirstOrDefault(e => e.login.Equals(user.login)); u.password = EncryptHelper.encryptPassword(password1); Logger.logToDB("Reset password to user " + u.login, entities, User.Identity.Name); entities.SaveChanges(); TempData["notifi"] = "true"; return(RedirectToAction("Index")); } }
public ActionResult Search(string searchText) { if (searchText.Length < 2) { return(View("ListComputers", new List <computer>())); } string searchTextUpper = searchText.ToUpper(); using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; var pc = entities.computers.Include(c => c.user).Include(c => c.computer_type).Where(c => c.name.Contains(searchText) || c.user.lastname.Contains(searchText) || c.user.firstname.Contains(searchText)); List <computer> computersList = pc.ToList(); if (computersList.Count == 1) { return(RedirectToAction("Index", "ComputerDetail", computersList.FirstOrDefault())); } return(View("ListComputers", pc.ToArray())); } }
public static bool checkExistComputer(string computer) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { return(checkExistComputer(computer, entities)); } }
public string AddAjax(string processor, string ram, string hdd) { int ramN = 0; int hddN = 0; if (!(Int32.TryParse(ram, out ramN) && Int32.TryParse(hdd, out hddN)) || processor == null) { return(null); } computer_parameters computerParameters = new computer_parameters(); computerParameters.hdd = hddN; computerParameters.ram = ramN; computerParameters.processor = processor; if (!Validator.validParameters(computerParameters)) { return(null); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.computer_parameters.Add(computerParameters); Logger.logParameters(computerParameters, "Add", User); entities.SaveChanges(); } return("{\"msg\":\"success\"}"); }
public ActionResult Save(Frycz_pcdb.user userIn) { if (!Validator.validUser(userIn)) { ModelState.AddModelError("valid", "Firstname or lastname is invalid."); return(View("AddUser", userIn)); } if (ModelState.IsValid) { if (Validator.checkExistUser(userIn)) { ModelState.AddModelError("exist", "User is already exist."); return(View("AddUser", userIn)); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.users.Add(userIn); Logger.logUser(userIn, "Add", User); entities.SaveChanges(); return(RedirectToAction("Index", "AllUsers")); } } return(View("AddUser", userIn)); }
public static bool checkExistUser(string firstname, string lastname) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { int count = entities.users.Count(e => e.lastname.Equals(lastname) && e.firstname.Equals(firstname)); return(count > 0); } }
public static void logToDB(string message, string userName) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { logToDB(message, entities, userName); entities.SaveChanges(); } }
public ActionResult Index() { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; return(View("AllUsers", entities.users.ToList())); } }
// GET: ComputerType public ActionResult Index() { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; return(View("AllComputerType", entities.computer_type.ToList())); } }
public ActionResult Index() { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; var comps = entities.computers.Include(c => c.o).Include(c => c.computer_brand).Include(c => c.user).Include(c => c.computer_parameters).Include(c => c.computer_type).ToList(); return(View("AllComputersView", comps)); } }
public ActionResult Index() { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; List <logging> log = entities.loggings.Include(e => e.registered_user).OrderByDescending(e => e.time).Take(100).ToList(); return(View("LoggingAll", log)); } }
public ActionResult Index() { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; var parameters = entities.computer_parameters.ToList(); return(View("AllParameters", parameters)); } }
public static void logToDB(string message, frycz_pcdbEntities entities, string userName) { logging logging = new logging(); logging.info = message; logging.time = DateTime.Now; logging.registered_user = entities.registered_user.FirstOrDefault(u => u.login.Equals((userName))); entities.loggings.Add(logging); }
// GET: Access public ActionResult Index() { ViewBag.noti = TempData["notifi"]; using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; List <registered_user> users = entities.registered_user.ToList(); return(View("AllRegisteredUser", users)); } }
public ActionResult Discard(computer computerIn) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { var comp = entities.computers.FirstOrDefault(c => c.idcomputer == computerIn.idcomputer); comp.discardedDate = DateTime.Now; entities.SaveChanges(); Logger.logComputer(comp, "Discard", User); return(RedirectToAction("Index", "ComputerDetail", comp)); } }
public ActionResult Delete(computer computerIn) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { var comp = entities.computers.FirstOrDefault(c => c.idcomputer == computerIn.idcomputer); entities.computers.Remove(comp); entities.SaveChanges(); Logger.logComputer(comp, "Delete", User); return(RedirectToAction("Index", "AllComputer", comp)); } }
// GET: ComputerDetail public ActionResult Index(computer computerIn) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; var comps = entities.computers.Where(c => c.idcomputer == computerIn.idcomputer).Include(c => c.user).Include(c => c.computer_parameters).Include(c => c.o) .Include(c => c.computer_type).Include(c => c.computer_brand).FirstOrDefault(); return(View("ComputerDetail", comps)); } }
public ActionResult AddForm(string firstname, int numberofadd) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { ViewBag.guar = DateTime.Now.AddYears(2).ToString("dd/MM/yyyy"); ViewBag.first = firstname.ToUpper(); ViewBag.numberofadd = numberofadd; makeViewBag(entities, new computer()); return(View("AddComputer")); } }
private ActionResult returnValidationMessage(computer computer, int count, FormCollection formCollection) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { ViewBag.guar = DateTime.Now.AddYears(2).ToString("dd/MM/yyyy"); ViewBag.numberofadd = count; ViewBag.first = formCollection["1"].ToUpper(); makeViewBag(entities, new computer()); return(View("AddComputer", computer)); } }
public ActionResult DeleteType(computer_type computerType) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { computer_type type = entities.computer_type.FirstOrDefault(t => t.idcomputer_type == computerType.idcomputer_type); entities.computer_type.Remove(type); Logger.logComputerType(type, "Delete", User); entities.SaveChanges(); return(RedirectToAction("Index", "ComputerType")); } }
public ActionResult Edit(o oIn) { if (oIn == null) { return(RedirectToAction("Index", "ComputerOS")); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { o oOut = entities.os.FirstOrDefault(e => e.idos == oIn.idos); return(View("EditOS", oOut)); } }
public static bool validType(computer_type computerType) { if (computerType == null || computerType.name == null || computerType.name.Equals(String.Empty)) { return(false); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { int count = entities.computer_type.Count(t => t.name.Equals(computerType.name)); return(count <= 0); } }
public ActionResult Index(Frycz_pcdb.user user) { Frycz_pcdb.user userIn = null; using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; if (user != null) { userIn = entities.users.Include(e => e.computers).FirstOrDefault(e => e.iduser == user.iduser); } return(View("UserDetail", userIn)); } }
public ActionResult Delete(o oIn) { if (oIn == null) { return(RedirectToAction("Index", "ComputerOS")); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.os.Remove(entities.os.FirstOrDefault(e => e.idos == oIn.idos)); entities.SaveChanges(); return(RedirectToAction("Index", "ComputerOS")); } }
public ActionResult Delete(Frycz_pcdb.user userIn) { if (userIn != null) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { Frycz_pcdb.user userdelete = entities.users.FirstOrDefault(u => u.iduser == userIn.iduser); entities.users.Remove(userdelete); entities.SaveChanges(); return(RedirectToAction("Index", "AllUsers")); } } return(null); }
public ActionResult EditModel(computer_brand brand) { if (brand == null) { return(RedirectToAction("Index")); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { computer_brand cb = entities.computer_brand.FirstOrDefault(e => e.idcumputer_brand == brand.idcumputer_brand); return(View("EditModel", cb)); } }
public static bool validParameters(computer_parameters parameters) { if (parameters == null) { return(false); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { int count = entities.computer_parameters.Count(e => e.hdd == parameters.hdd && e.processor.Equals(parameters.processor) && e.ram == parameters.ram); return(count <= 0); } }
public ActionResult Edit(computer_parameters parameters) { if (parameters == null) { return(RedirectToAction("Index", "ComputerParameters")); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { computer_parameters p = entities.computer_parameters.FirstOrDefault(e => e.idcomputer_parameters == parameters.idcomputer_parameters); return(View("EditParameters", p)); } }
public ActionResult Index(computer computer) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.Configuration.LazyLoadingEnabled = false; var comp = entities.computers.Where(c => c.idcomputer == computer.idcomputer).Include(c => c.user) .Include(c => c.computer_parameters).Include(c => c.o) .Include(c => c.computer_type).Include(c => c.computer_brand).FirstOrDefault(); // for dropdown list makeViewBag(entities, comp); return(View("EditComputer", comp)); } }