예제 #1
0
        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"));
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
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"));
            }
        }
예제 #4
0
        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"));
            }
        }
예제 #5
0
        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\"}");
        }
예제 #6
0
 public static void logComputerType(computer_type computerType, string operationMessage, IPrincipal user)
 {
     logToDB(operationMessage + " computer type: " + computerType.name, user);
 }
예제 #7
0
 public ActionResult EditComputerType(computer_type computerType)
 {
     return(View("EditComputerType", computerType));
 }