public ActionResult Edit([Bind(Include = "Id,Name")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
 public ActionResult Edit([Bind(Include = "Id,City,Street,ZipCode")] Adress adress)
 {
     if (ModelState.IsValid)
     {
         db.Entry(adress).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(adress));
 }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "Id,Name,AccountNumber")] BankAccount bankAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bankAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bankAccount));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Category_Id")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Category_Id = new SelectList(db.Category, "Id", "Name", product.Category_Id);
     return(View(product));
 }
        public async Task <ActionResult> Edit(
            [Bind(Include = "Id,Name,InvoiceNo,Purschace,Content,Description,Expectations,Cost,Start,Pending,InProgress,End,Product_Id,AppType_Id,Realization_Id,Statue_Id,Result_Id,Client_Id,Employee_Id")] Application application, string oldStatue)
        {
            if (IsPreviousStatus(application, oldStatue))
            {
                ModelState.AddModelError(string.Empty, "Nie możesz zmienić statusu na poprzedni.");
            }

            application.Statue = db.Statue.FirstOrDefault(s => s.Id == application.Statue_Id);
            application.Result = db.Result.FirstOrDefault(p => p.Id == application.Result_Id);

            if (application.Statue?.EName == EStatue.Sended && application.Result == null)
            {
                ModelState.AddModelError(string.Empty, "Nie wybrano rezultatu.");
            }

            if (ModelState.IsValid)
            {
                db.Entry(application).State = EntityState.Modified;
                if (IsStatueChanged(application, oldStatue))
                {
                    AssignEmployee(application);
                    SetStatusDate(application);
#if !DEBUG
                    var mailMessage = PrepareChangeStatusMessage(application);
                    var mailEntity  = new Email {
                        Sender         = mailMessage.From.ToString(),
                        Reciper        = mailMessage.To.ToString(),
                        Subject        = mailMessage.Subject,
                        Content        = mailMessage.Body,
                        Application_Id = application.Id,
                        PostDate       = DateTime.Now
                    };
                    await SendMessage(mailMessage);

                    SaveMessage(mailEntity);
#endif
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AppType_Id     = new SelectList(db.AppType, "Id", "Name", application.AppType_Id);
            ViewBag.Client_Id      = new SelectList(db.User.Where(u => u.Role.Name == "Klient"), "Id", "Identificator", application.Client_Id);
            ViewBag.Employee_Id    = new SelectList(db.User.Where(u => u.Role.Name == "Serwisant"), "Id", "Identificator", application.Employee_Id);
            ViewBag.Product_Id     = new SelectList(db.Product, "Id", "Name", application.Product_Id);
            ViewBag.Realization_Id = new SelectList(db.Realization, "Id", "Name", application.Realization_Id);
            ViewBag.Result_Id      = new SelectList(db.Result, "Id", "Name", application.Result_Id);
            ViewBag.Statue_Id      = new SelectList(db.Statue, "Id", "Name", application.Statue_Id);
            return(View(application));
        }
        public ActionResult ConfirmEmail(string token, string email)
        {
            using (var context = new RmaEntities()) {
                var userId = int.Parse(HashHelper.Decrypt(token, email));
                var user   = context.User.FirstOrDefault(u => u.Id == userId && u.Email == email);
                if (user == null)
                {
                    return(null);
                }

                user.EmailConfirmed = true;
                context.Entry(user).Property(p => p.EmailConfirmed).IsModified = true;
                context.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
Exemple #7
0
        public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Phone,Email,Password,Role_Id,Adress_Id,BankAccount_Id")] User user, [Bind(Include = "City,Street,ZipCode")] Adress adress,
                                 [Bind(Include = "Name,AccountNumber")] BankAccount bankAccount)
        {
            var lol  = bankAccount == null;
            var lol9 = adress == null;

            if (ModelState.IsValid)
            {
                RMASystem.User.SetFirstLetterOfNameToUpper(user);
                db.Entry(user).State = EntityState.Modified;
                user.Adress          = adress;
                user.BankAccount     = bankAccount;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Adress_Id      = new SelectList(db.Adress, "Id", "City", user.Adress_Id);
            ViewBag.BankAccount_Id = new SelectList(db.BankAccount, "Id", "Name", user.BankAccount_Id);
            ViewBag.Role_Id        = new SelectList(db.Role, "Id", "Name", user.Role_Id);
            return(View(user));
        }