Esempio n. 1
0
        public ActionResult Edit(User user, string password, string roleId)
        {
            if (ModelState.IsValid)
            {
                User us   = _userDao.GetById(user.Id);
                Role role = _roleDao.GetById(int.Parse(roleId));
                us.Name       = user.Name;
                us.Address    = user.Address;
                us.Profession = user.Profession;
                us.Email      = user.Email;
                us.Phone      = user.Phone;
                if (password.Length > 0)
                {
                    us.Password = EncryptPassword(password);
                }
                us.Surname = user.Surname;
                us.Role    = role;

                _userDao.Update(us);
                return(RedirectToAction("Index", "User"));
            }

            ViewBag.roles = _roles;
            return(View("Detail", user));
        }
Esempio n. 2
0
        public ActionResult CreateEmployee()
        {
            RoleDao      rDao  = new RoleDao();
            IList <Role> roles = new List <Role>();

            roles.Add(rDao.GetById(212));
            roles.Add(rDao.GetById(222));
            ViewBag.Roles = roles;
            ViewBag.Mark  = "User";

            return(View());
        }
Esempio n. 3
0
        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"));
        }
Esempio n. 4
0
        public ActionResult UpdateAddress(FitnessUser fitnessUser, int roleId, int addressId)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserDao    uDao = new UserDao();
                    RoleDao    rDao = new RoleDao();
                    AddressDao aDao = new AddressDao();
                    Address    a    = new Address();

                    fitnessUser.Address.Id = addressId;
                    fitnessUser.Role       = rDao.GetById(roleId);

                    a.Id           = addressId;
                    a.Country      = fitnessUser.Address.Country;
                    a.Street       = fitnessUser.Address.Street;
                    a.StreetNumber = fitnessUser.Address.StreetNumber;
                    a.Town         = fitnessUser.Address.Town;
                    a.Zip          = fitnessUser.Address.Zip;


                    aDao.Update(a);
                    uDao.Update(fitnessUser);

                    TempData["succes"] = "Úprava adresy proběhlo úspěšně.";
                }
                else
                {
                    return(View("EditAddress", fitnessUser));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 5
0
        public void GetById_NotNullTest(int roleId)
        {
            var result = _roleDao.GetById(roleId);

            Assert.NotNull(result);
        }
Esempio n. 6
0
 public RoleObject GetById(byte RoleID)
 {
     return(ModelRole.GetById(RoleID));
 }