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 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 SaveAdd(computer_type computerType) { if (!Validator.validType(computerType)) { ModelState.AddModelError("exist", "Computer type is invalid or in use."); return(View("AddComputerType", computerType)); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.computer_type.Add(computerType); Logger.logComputerType(computerType, "Add", User); entities.SaveChanges(); return(RedirectToAction("Index", "ComputerType")); } }
public ActionResult EditSave(computer_type computerType) { using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { if (!Validator.validType(computerType)) { ModelState.AddModelError("exist", "Computer type is invalid or in use."); return(View("EditComputerType", computerType)); } computer_type type = entities.computer_type.FirstOrDefault(t => t.idcomputer_type == computerType.idcomputer_type); type.name = computerType.name; Logger.logComputerType(type, "Edit", User); entities.SaveChanges(); return(RedirectToAction("Index", "ComputerType")); } }
public string addJax(string name) { computer_type computerType = new computer_type(); computerType.name = name; if (!Validator.validType(computerType)) { return(null); } using (frycz_pcdbEntities entities = new frycz_pcdbEntities()) { entities.computer_type.Add(computerType); Logger.logComputerType(computerType, "Edit", User); entities.SaveChanges(); } return("{\"msg\":\"success\"}"); }
public static void logComputerType(computer_type computerType, string operationMessage, IPrincipal user) { logToDB(operationMessage + " computer type: " + computerType.name, user); }
public ActionResult EditComputerType(computer_type computerType) { return(View("EditComputerType", computerType)); }