コード例 #1
0
        public RegistrationResponse Registration(AdminRegistrationRequest adminDetails)
        {
            try
            {
                RegistrationResponse responseData = null;
                adminDetails.Password = EncodeDecode.EncodePasswordToBase64(adminDetails.Password);
                var adminData = new Users
                {
                    FirstName    = adminDetails.FirstName,
                    LastName     = adminDetails.LastName,
                    Email        = adminDetails.Email,
                    Password     = adminDetails.Password,
                    IsActive     = true,
                    UserRole     = "Admin",
                    CreatedDate  = DateTime.Now,
                    ModifiedDate = DateTime.Now
                };

                _appDBContext.Add(adminData);
                _appDBContext.SaveChanges();

                responseData = SecurityRepository.ResponseData(adminData);
                return(responseData);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public RegistrationResponse Login(LoginRequest loginDetails)
        {
            try
            {
                RegistrationResponse responseData = null;
                loginDetails.Password = EncodeDecode.EncodePasswordToBase64(loginDetails.Password);

                var adminData = _appDBContext.Users
                                .Where(user => user.Email == loginDetails.Email && user.Password == loginDetails.Password)
                                .FirstOrDefault();

                if (adminData != null)
                {
                    responseData = SecurityRepository.ResponseData(adminData);
                }
                return(responseData);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }