public Boolean login(AdminBindingModel model)
        {
            Admin element = context.Admins.FirstOrDefault(rec => rec.Login == model.Login);

            if (element != null)
            {
                if (element.Password.Equals(model.Password))
                {
                    return(true);
                }
            }
            return(false);
        }
        public void AddElement(AdminBindingModel model)
        {
            Admin element = context.Admins.FirstOrDefault(rec => rec.AdminFIO ==
                                                          model.AdminFIO);

            if (element != null)
            {
                throw new Exception("Уже есть клиент с таким ФИО");
            }
            context.Admins.Add(new Admin
            {
                AdminFIO = model.AdminFIO
            });
            context.SaveChanges();
        }
        public void UpdElement(AdminBindingModel model)
        {
            Admin element = source.Admins.FirstOrDefault(rec => rec.AdminFIO ==
                                                         model.AdminFIO && rec.Id != model.Id);

            if (element != null)
            {
                throw new Exception("Уже есть клиент с таким ФИО");
            }
            element = source.Admins.FirstOrDefault(rec => rec.Id == model.Id);
            if (element == null)
            {
                throw new Exception("Элемент не найден");
            }
            element.AdminFIO = model.AdminFIO;
        }
        public void AddElement(AdminBindingModel model)
        {
            Admin element = source.Admins.FirstOrDefault(rec => rec.AdminFIO ==
                                                         model.AdminFIO);

            if (element != null)
            {
                throw new Exception("Уже есть клиент с таким ФИО");
            }
            int maxId = source.Admins.Count > 0 ? source.Admins.Max(rec => rec.Id) : 0;

            source.Admins.Add(new Admin
            {
                Id       = maxId + 1,
                AdminFIO = model.AdminFIO
            });
        }
        private void loginButton_Click(object sender, EventArgs e)
        {
            AdminBindingModel admin = new AdminBindingModel();

            admin.Login    = login.Text;
            admin.Password = password.Text;
            if (service.login(admin))
            {
                var form = Container.Resolve <FormMain>();
                this.Visible = false;
                form.ShowDialog();
                this.Visible = true;
            }
            else
            {
                MessageBox.Show("Неверный логин или пароль.");
            }
        }
        public async Task <IHttpActionResult> PostAsync(int theaterId, AdminBindingModel theaterAdmin)
        {
            ISofAUser user = new ISofAUser
            {
                UserName    = theaterAdmin.Email,
                Name        = theaterAdmin.Name,
                Surname     = theaterAdmin.Surname,
                Email       = theaterAdmin.Email,
                City        = theaterAdmin.City,
                PhoneNumber = theaterAdmin.PhoneNumber,
            };

            IdentityResult result = await UserManager.CreateAsync(user, "Password1!");

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            ISofAUserDTO admin = null;

            if (theaterAdmin.AdminType == 0)
            {
                admin = _adminService.AddTheaterAdmin(theaterId, user);
            }
            else if (theaterAdmin.AdminType == 1)
            {
                admin = _adminService.AddFanZoneAdmin(theaterId, user);
            }

            if (admin != null)
            {
                return(Ok(admin));
            }

            return(BadRequest());
        }
        public async Task <IHttpActionResult> PostSysAdminAsync(AdminBindingModel theaterAdmin)
        {
            ISofAUser user = new ISofAUser
            {
                UserName      = theaterAdmin.Email,
                Name          = theaterAdmin.Name,
                Surname       = theaterAdmin.Surname,
                Email         = theaterAdmin.Email,
                City          = theaterAdmin.City,
                PhoneNumber   = theaterAdmin.PhoneNumber,
                ISofAUserRole = ISofAUserRole.SysAdmin
            };

            IdentityResult result = await UserManager.CreateAsync(user, "Admin123!");

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }
            else
            {
                return(Ok());
            }
        }