Esempio n. 1
0
        public JsonResult SaveRole(Account account)
        {
            var role = db.Account.Where(x => x.IdUser == account.IdUser).FirstOrDefault();

            if (role != null)
            {
                role.IdRole = account.IdRole;
            }
            db.SaveChanges();

            return(Json(new JsonSerializerSettings()));
        }
Esempio n. 2
0
        public IActionResult Registration([FromForm] Account registration)
        {
            if (registration.Name != null && registration.Password != null && registration.Phone != null && registration.Email != null)
            {
                bool   Status  = false;
                string message = "";

                var IsExist = IsEmailExist(registration.Email);
                if (IsExist)
                {
                    ModelState.AddModelError("EmailExist", "Такой электронный адрес уже существует");
                    return(View(registration));
                }

                registration.ActivationCode = Guid.NewGuid();

                registration.Password = SimpleHash.ComputeHash(registration.Password);

                registration.Verified           = false;
                registration.DateOfRegistration = DateTime.Now;

                Account account = db.Account.FirstOrDefault(u => u.Email == registration.Email);

                if (account != null)
                {
                    ModelState.AddModelError("", "Такой пользователь уже есть");
                }
                registration.IdRole = 1;

                db.Account.Add(registration);
                db.SaveChanges();

                SendVerificationLinkEmail(registration.Email, registration.ActivationCode.ToString());
                message = "Ссылка на активацию аккаунта " +
                          " была отправлена на указанную почту: " + registration.Email;
                Status = true;

                ModelState.Clear();
                ViewBag.Message = registration.Name + " " + " успешно зарегистрирован(a)";

                ViewBag.Message = message;
                ViewBag.Status  = Status;
            }
            else
            {
                return(View());
            }
            return(View(registration));
        }
Esempio n. 3
0
        public IActionResult EditUser([FromBody] Account account)
        {
            var upd = db.Account.Where(x => x.IdUser == account.IdUser).FirstOrDefault();

            if (upd != null)
            {
                upd.Name       = account.Name;
                upd.Surname    = account.Surname;
                upd.Patronymic = account.Patronymic;
                upd.Email      = account.Email;
                upd.Phone      = account.Phone;
            }

            db.SaveChanges();
            return(Ok(account));
        }
Esempio n. 4
0
        public IActionResult ClientForm(string jClient)
        {
            Clients clients;

            try
            {
                clients      = JsonConvert.DeserializeObject <Clients>(jClient);
                clients.Date = DateTime.Now;
                db.Clients.Add(clients);
                db.SaveChanges();
            }
            catch
            {
                ViewBag.Message = "Заявка не была отправлена";
            }

            return(Ok());
        }
Esempio n. 5
0
        public IActionResult CancelClient(string jClient)
        {
            Clients clients;

            clients = JsonConvert.DeserializeObject <Clients>(jClient);
            var UpdateClient = db.Clients.SingleOrDefault(c => c.IdClient == clients.IdClient);

            if (UpdateClient != null)
            {
                UpdateClient.IsCancel = true;
                db.SaveChanges();
            }

            return(RedirectToAction("/Clients"));
        }