//Обновление данных о мастере
        public ActionResult UpdateResident(RegisterMasterModel model, HttpPostedFileBase upload)
        {
            UserContext db = new UserContext();



            byte[] imageData = null;
            // считываем переданный файл в массив байтов
            if (upload == null)
            {
                imageData = new byte[] {};
            }
            else
            {
                using (var binaryReader = new BinaryReader(upload.InputStream))
                {
                    imageData = binaryReader.ReadBytes(upload.ContentLength);
                }
            }

            // установка массива байтов
            model.Picture = imageData;

            if (model.Picture.Length != 0)
            {
                Utilities.SendDbUtility.CreatePicture(model.Picture, model.id);
            }



            if (model.Offers == null)
            {
                TempData["WrongMessage"] = "Выберите предоставляемые услуги!";
                return(RedirectToAction("PersonalData", "TimerClub"));
            }

            //Если пароль введен верно
            if (SendDbUtility.ComparePassword(model.Password, User.Identity.Name))
            {
                Utilities.SendDbUtility.ChangeResident(model);
                TempData["SuccessMessage"] = "Данные изменены!";
                return(RedirectToAction("PersonalData", "TimerClub"));
            }
            else
            {
                TempData["WrongMessage"] = "Пароль введен не верно!";
                return(RedirectToAction("PersonalData", "TimerClub"));
            }
        }
        public ActionResult PasswordChange(ChangePasswordModel model)
        {
            if (!SendDbUtility.ComparePassword(model.OldPassword, User.Identity.Name))
            {
                TempData["WrongMessage"] = "Пароль введен не верно!";
                return(RedirectToAction("PasswordView", "TimerClub"));
            }

            if (SendDbUtility.ChangePassword(User.Identity.Name, model.NewPassword))
            {
                TempData["SuccessMessage"] = "Пароль успешно изменен!";
                return(RedirectToAction("PersonalData", "TimerClub"));
            }
            else
            {
                TempData["WrongMessage"] = "Ошибка!";
                return(RedirectToAction("PasswordView", "TimerClub"));
            }
        }
        public ActionResult LoginMaster(LoginMaster model)
        {
            if (SendDbUtility.ComparePassword(model.Password, model.Email))
            {
                FormsAuthentication.SetAuthCookie(model.Email, true);
                var resident = GetData.GetDataResident(model.Email);
                Response.Cookies["ResidentName"].Value    = Server.UrlEncode(resident.Name);
                Response.Cookies["ResidentSurname"].Value = Server.UrlEncode(resident.Surname);
                Response.Cookies["City"].Value            = Server.UrlEncode(resident.City);

                var cookie = new HttpCookie("SalonId")
                {
                    Expires = DateTime.Now.AddDays(-1d)
                };
                Response.Cookies.Add(cookie);

                return(RedirectToAction("FindWorkPlaces", "TimerClub"));
            }
            return(RedirectToAction("MainPage", "TimerClub"));
        }