public ActionResult UpdateUser(FitnessUser fitnessUser, HttpPostedFileBase picture, int roleId, int addressId) { try { if (ModelState.IsValid) { if (picture != null) { ImageClass.ImageMethod(picture, "FitnessUser", out string bigImageName, out string smallImageName, out string tempData); if (tempData != null) { TempData["warning"] = tempData; } if (fitnessUser.SmallImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/FitnessUser/" + fitnessUser.SmallImageName)); } if (fitnessUser.BigImageName != null) { System.IO.File.Delete(Server.MapPath("~/Uploads/FitnessUser/" + fitnessUser.BigImageName)); } fitnessUser.BigImageName = bigImageName; fitnessUser.SmallImageName = smallImageName; } UserDao uDao = new UserDao(); RoleDao rDao = new RoleDao(); AddressDao aDao = new AddressDao(); fitnessUser.Role = rDao.GetById(roleId); fitnessUser.Address = aDao.GetById(addressId); uDao.Update(fitnessUser); } else { return(View("EditUser", fitnessUser)); } if (TempData["warning"] == null) { TempData["succes"] = "Úprava Vašeho profilu proběhla úspěšně."; } } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("Index", "Home")); }