Beispiel #1
0
 protected override void DisposeCore()
 {
     if (_dataContext != null)
     {
         _dataContext.Dispose();
     }
 }
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                if (user.PhotoFile != null)
                {
                    var pic    = string.Empty;
                    var folder = "~/Content/Users";
                    var file   = string.Format("{0}.jpg", user.UserId);

                    var response = FilesHelper.UploadPhoto(user.PhotoFile, folder, file);
                    if (response)
                    {
                        pic        = string.Format("{0}/{1}", folder, file);
                        user.Photo = pic;
                    }
                }

                var db2         = new EcommerceContext();
                var currentUser = db2.Users.Find(user.UserId);
                if (currentUser.UserName != user.UserName)
                {
                    UsersHelper.UpdateUserName(currentUser.UserName, user.UserName);
                }
                db2.Dispose();
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            ViewBag.CityId         = new SelectList(CombosHelper.GetCities(), "CityId", "Name", user.CityId);
            ViewBag.CompanyId      = new SelectList(CombosHelper.GetCompanys(), "CompanyId", "Name", user.CompanyId);
            ViewBag.DepartamentsId = new SelectList(CombosHelper.GetDepartments(), "DepartamentsId", "Name", user.DepartamentsId);
            return(View(user));
        }
Beispiel #3
0
 public void Dispose()
 {
     if (dbContext != null)
     {
         dbContext.Dispose();
     }
 }
Beispiel #4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #5
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     _disposed = true;
 }
Beispiel #6
0
        public virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    _context.Dispose();
                }
            }

            disposed = true;
        }
Beispiel #7
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         var db2         = new EcommerceContext();
         var currentUser = db2.Users.Find(user.UserId);
         if (currentUser.UserName != user.UserName)
         {
             UserHelper.UpdateUserName(currentUser.UserName, user.UserName);
         }
         db2.Dispose();
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CityId       = new SelectList(CombosHelper.GetCities(), "CityId", "Name", user.CityId);
     ViewBag.CompanyId    = new SelectList(CombosHelper.GetCompanies(), "CompanyId", "Name", user.CompanyId);
     ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", user.DepartmentId);
     return(View(user));
 }
        public ActionResult Edit(Customer customer)
        {
            if (ModelState.IsValid)
            {
                if (customer.PhotoFile != null)
                {
                    var file   = string.Format("{0}.jpg", customer.CustomerID);
                    var folder = "~/Content/Customers";
                    var resp   = fileHelper.UploadPhoto(customer.PhotoFile, folder, file);
                    customer.Photo = string.Format("{0}/{1}", folder, file);
                }

                var db2             = new EcommerceContext();
                var currentCustomer = db2.Users.Find(customer.CustomerID);

                if (currentCustomer.UserName != customer.UserName)
                {
                    userHelper.updateUserName(currentCustomer.UserName, customer.UserName);
                }

                db2.Dispose();


                db.Entry(customer).State = EntityState.Modified;
                var response = dbHelper.saveChanges(db);
                if (response.Succeded)
                {
                    //TODO: validar cuando el correo del customer cambie
                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError(string.Empty, response.Message);
            }
            ViewBag.CityID       = new SelectList(comboHelper.GetCities(customer.DepartmentID), "CityID", "Name");
            ViewBag.DepartmentID = new SelectList(comboHelper.GetDepartments(), "DepartmentID", "Name");
            return(View(customer));
        }
Beispiel #9
0
 public void Dispose()
 {
     db.Dispose();
 }
Beispiel #10
0
 public void Dispose()
 {
     userContext.Dispose();
     db.Dispose();
 }
 public void Dispose()
 {
     _ecommerceContext.Dispose();
 }
Beispiel #12
0
 public void Dispose() //cierran conexiones
 {
     userContext.Dispose();
     db.Dispose();
 }