Пример #1
0
 public ActionResult Create([Bind(Include = "ID,Title,tel")] Unit unit)
 {
     if (ModelState.IsValid)
     {
         db.Unit.Add(unit);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(unit));
 }
Пример #2
0
        public ActionResult Create([Bind(Include = "ID,Title")] TypeOFService typeOFService)
        {
            if (ModelState.IsValid)
            {
                db.TypeOFService.Add(typeOFService);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(typeOFService));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "ID,StartDate,Title,Description")] PeriodicVisits periodicVisits)
        {
            if (ModelState.IsValid)
            {
                db.PeriodicVisits.Add(periodicVisits);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(periodicVisits));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "OutputID,UserID,Description,InputDate")] Output output)
        {
            if (ModelState.IsValid)
            {
                db.Output.Add(output);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(output));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "RoleID,RoleTitle,RoleName")] Role role)
        {
            if (ModelState.IsValid)
            {
                db.Role.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "ActionID,Title")] Action action1)
        {
            if (ModelState.IsValid)
            {
                db.Action.Add(action1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(action1));
        }
        public ActionResult Create([Bind(Include = "HardwareTypeID,Name,SubArea")] HardwareType hardwareType)
        {
            if (ModelState.IsValid)
            {
                db.HardwareType.Add(hardwareType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hardwareType));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "ID,Name,Version,Type")] Software software)
        {
            if (ModelState.IsValid)
            {
                db.Software.Add(software);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(software));
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "ID,Title,SubUnitID")] ComputerType computerType)
        {
            if (ModelState.IsValid)
            {
                db.ComputerType.Add(computerType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(computerType));
        }
Пример #10
0
        public ActionResult Create([Bind(Include = "WarehouseID,HardwareID,Tedad")] WareHouse wareHouse)
        {
            if (ModelState.IsValid)
            {
                db.WareHouse.Add(wareHouse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HardwareID = new SelectList(db.Hardware, "ID", "Name", wareHouse.HardwareID);
            return(View(wareHouse));
        }
Пример #11
0
        public ActionResult Create([Bind(Include = "InputID,FactorNo,UserID,Description,InputDate")] Input input)
        {
            if (ModelState.IsValid)
            {
                db.Input.Add(input);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID = new SelectList(db.User, "userID", "UserName", input.UserID);
            return(View(input));
        }
Пример #12
0
        public ActionResult Create([Bind(Include = "ID,Name,Type")] Hardware hardware)
        {
            if (ModelState.IsValid)
            {
                db.Hardware.Add(hardware);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Type = new SelectList(db.HardwareType, "HardwareTypeID", "Name", hardware.Type);
            return(View(hardware));
        }
        public ActionResult Create([Bind(Include = "ComputerHardwareID,ComputerID,HardwareID,AmvalCode,Serial")] ComputerHardware computerHardware)
        {
            if (ModelState.IsValid)
            {
                db.ComputerHardware.Add(computerHardware);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = computerHardware.ComputerID }));
            }

            ViewBag.ComputerID = new SelectList(db.Computer, "Computer_ID", "Computer_ID", computerHardware.ComputerID);
            ViewBag.HardwareID = new SelectList(db.Hardware, "ID", "Name", computerHardware.HardwareID);
            return(View(computerHardware));
        }
        public ActionResult Create([Bind(Include = "InputDetailID,InputID,HardwareID,Tedad")] InputDetail inputDetail)
        {
            if (ModelState.IsValid)
            {
                db.InputDetail.Add(inputDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HardwareID = new SelectList(db.Hardware, "ID", "Name", inputDetail.HardwareID);
            ViewBag.InputID    = new SelectList(db.Input, "InputID", "FactorNo", inputDetail.InputID);
            return(View(inputDetail));
        }
Пример #15
0
        public ActionResult Create([Bind(Include = "OutputDetailID,HardwareID,Tedad,OutputID")] OutputDetail outputDetail)
        {
            if (ModelState.IsValid)
            {
                db.OutputDetail.Add(outputDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HardwareID = new SelectList(db.Hardware, "ID", "Name", outputDetail.HardwareID);
            ViewBag.OutputID   = new SelectList(db.Output, "OutputID", "Description", outputDetail.OutputID);
            return(View(outputDetail));
        }
Пример #16
0
        public ActionResult Create([Bind(Include = "Computer_ID,unit,TypeOfComputer,ClientUser,ComputerName,UserName,AmvalCode,Serial")] Computer computer)
        {
            if (ModelState.IsValid)
            {
                db.Computer.Add(computer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TypeOfComputer = new SelectList(db.ComputerType, "ID", "Title", computer.TypeOfComputer);
            ViewBag.unit           = new SelectList(db.Unit, "ID", "Title", computer.unit);
            return(View(computer));
        }
Пример #17
0
 public ActionResult ReturnCom([Bind(Include = "id,ComputerID,UserID,ComputerName,DeliveryDate,ReturnDate")] Deliver deliver)
 {
     if (ModelState.IsValid && deliver.DeliveryDate < deliver.ReturnDate)
     {
         deliver.ReturnDate      = deliver.ReturnDate == null ? deliver.ReturnDate : DateConvertor.ToMiladi((DateTime)deliver.ReturnDate);
         deliver.DeliveryDate    = DateConvertor.ToMiladi((DateTime)deliver.DeliveryDate);
         db.Entry(deliver).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     if (deliver.DeliveryDate >= deliver.ReturnDate)
     {
         ViewBag.error = true;
     }
     ViewBag.ComputerID = new SelectList(db.Computer, "Computer_ID", "Computer_ID", deliver.ComputerID);
     ViewBag.UserID     = new SelectList(db.User, "userID", "UserName", deliver.UserID);
     return(View(deliver));
 }
Пример #18
0
        public ActionResult Create([Bind(Include = "ID,dateOfService,Computer_ID,SoftwareID,Action,DisablementID,ICTUser,PeriodicVisitsID,TypeOfServices")] service service)
        {
            if (ModelState.IsValid)
            {
                service.ICTUser       = db.User.SingleOrDefault(u => u.UserName == User.Identity.Name).userID;
                service.dateOfService = DateConvertor.ToMiladi(service.dateOfService);
                // service.ServiceImage.Add(new ServiceImage() {ServiceID=service.ID,FileName=""});
                db.service.Add(service);
                db.SaveChanges();
                return(RedirectToAction("Index", new { comid = service.Computer_ID }));
            }

            ViewBag.Action           = new SelectList(db.Action, "ActionID", "Title", service.Action);
            ViewBag.Computer_ID      = new SelectList(db.Computer, "Computer_ID", "Computer_ID", service.Computer_ID);
            ViewBag.DisablementID    = new SelectList(db.Disablement, "ID", "ComputerID", service.DisablementID);
            ViewBag.PeriodicVisitsID = new SelectList(db.PeriodicVisits, "ID", "Title", service.PeriodicVisitsID);
            ViewBag.SoftwareID       = new SelectList(db.Software, "ID", "Name", service.SoftwareID);
            ViewBag.TypeOfServices   = new SelectList(db.TypeOFService, "ID", "Title", service.TypeOfServices);
            return(View(service));
        }
Пример #19
0
        public ActionResult Create([Bind(Include = "userID,RoleID,UserName,Password,Mobile,ActiveCode,IsActive,RegisterDate,PersonalImage,Name,DomainUserName")] User user)
        {
            if (ModelState.IsValid)
            {
                user.ActiveCode    = Guid.NewGuid().ToString();
                user.IsActive      = true;
                user.RegisterDate  = DateTime.Now;
                user.PersonalImage = "images.jpg";
                user.Password      = FormsAuthentication.HashPasswordForStoringInConfigFile(user.Password, "MD5");
                db.User.Add(user);


                try
                {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.RoleID = new SelectList(db.Role, "RoleID", "RoleTitle", user.RoleID);
            return(View(user));
        }
Пример #20
0
 public ActionResult ChangePassword(ChangePasswordViewModel change)
 {
     if (ModelState.IsValid)
     {
         var user = db.User.Single(u => u.UserName == User.Identity.Name);
         ViewBag.Name = user;
         string oldPasswordhash = FormsAuthentication.HashPasswordForStoringInConfigFile(change.OldPassword, "MD5");
         if (user.Password == oldPasswordhash)
         {
             string hashNewPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(change.Password, "MD5");
             user.Password = hashNewPassword;
             db.SaveChanges();
             ViewBag.Success = true;
         }
         else
         {
             ModelState.AddModelError("oldPassword", "کلمه عبور فعلی صحیح نمی باشد.");
         }
     }
     return(View("SuccessChangPassword"));
 }