Пример #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Пример #2
0
 public void Dispose()
 {
     userContext.Dispose();
     db.Dispose();
 }
Пример #3
0
        public ActionResult Edit(User user)
        {
            if (ModelState.IsValid)
            {
                if (user.PhotoFile != null)
                {
                    var folder = "~/Content/Photos";

                    var pic = string.Empty;

                    var file = string.Format("{0}.jpg", user.UserID);

                    var response0 =
                        FilesHelpers.
                        UploadPhoto(
                            user.PhotoFile,
                            folder,
                            file);

                    if (response0)
                    {
                        pic = string.Format("{0}/{1}", folder, user.UserID);

                        user.Photo = pic;
                    }
                }

                var db2 = new CenECommerceContext();

                var currentUser = db2.Users.Find(user.UserID);

                if (currentUser.UserName != null)
                {
                    UsersHelpers.UpdateUserName(currentUser.UserName, user.UserName);
                }

                db2.Dispose();

                db.Entry(user).State =
                    EntityState.Modified;

                var response = DBHelpers.SaveChanges(db);

                if (response.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError(
                    string.Empty, response.Message);
            }

            ViewBag.CityId =
                new SelectList(
                    ComboBoxHelpers.
                    GetCities(user.StateId),
                    "CityId",
                    "NameCity",
                    user.CityId);

            ViewBag.CompanyId =
                new SelectList(
                    ComboBoxHelpers.
                    GetCompanies(),
                    "CompanyId",
                    "NameCompany",
                    user.CompanyId);

            ViewBag.StateId =
                new SelectList(
                    ComboBoxHelpers.
                    GetStates(),
                    "StateId",
                    "NameState",
                    user.StateId);

            return(View(user));
        }
Пример #4
0
 public void Dispose()
 {
     db.Dispose();
 }