예제 #1
0
 public ActionResult ChangePassword(ChangePassword cp)
 {
     if (ModelState.IsValid)
     {
         var user = _context.Users.Where(
             x => x.UserName.Equals(User.Identity.Name) &&
             x.Password.Equals(cp.CurrentPassword))
                    .FirstOrDefault();
         if (user == null)
         {
             ModelState.AddModelError("CurrentPassword", "Current password does not match");
         }
         else if (cp.CurrentPassword.Equals(cp.NewPassword))
         {
             ModelState.AddModelError("NewPassword", "New password cannot be same as current password");
         }
         else
         {
             user.Password = cp.NewPassword;
             _context.Entry(user).State = System.Data.Entity.EntityState.Modified;
             _context.SaveChanges();
             ViewData["message"] = "Password updated successfully";
         }
     }
     return(View());
 }
예제 #2
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Address1,Address2,Pincode,City,State,Phone,Mobile,GSTNO,ContactPerson", Exclude = "AddedBy,AddedOn")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Entry(customer).State = EntityState.Modified;
                customer.AddedBy         = HttpContext.User.Identity.Name;
                customer.AddedOn         = DateTime.Now;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(customer));
        }
예제 #3
0
 public ActionResult Edit(Challan ch)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(ch).State = System.Data.Entity.EntityState.Modified;
         _context.SaveChanges();
         return(RedirectToAction("Index", new { id = ch.CustomerId }));
     }
     else
     {
         ViewData["CustomerList"] = new SelectList(
             _context.Customers
             .Select(x => new { x.Id, x.Name })
             .OrderBy(x => x.Name)
             .ToList(), "Id", "Name", ch.CustomerId);
     }
     return(View(ch));
 }