Exemplo n.º 1
0
        public RequestMessageFormat <UserCurrentRequestStatusDTO> Add(UserCurrentRequestStatusDTO userCurrentRequestStatusDTO)
        {
            RequestMessageFormat <UserCurrentRequestStatusDTO> response = new RequestMessageFormat <UserCurrentRequestStatusDTO>();

            try
            {
                userCurrentRequestStatusDTO.CreatedOn  = DateTime.Now;
                userCurrentRequestStatusDTO.ModifiedOn = DateTime.Now;
                UserCurrentRequestStatus userCurrentRequestStatus = this.AutoMapperConfigurations.UserCurrentRequestStatusDTOToUserCurrentRequestStatus(userCurrentRequestStatusDTO);
                bool isAdded = this.UserCurrentRequestStatusRepository.Add(userCurrentRequestStatus);

                if (isAdded)
                {
                    response.Message = "Added Successfully";
                    userCurrentRequestStatusDTO.ID = userCurrentRequestStatus.ID;

                    response.Data    = userCurrentRequestStatusDTO;
                    response.Success = true;
                    return(response);
                }
            }
            catch (Exception)
            {
                response.Message = "Some Error Occurred while adding data please try again";
                response.Data    = null;
                response.Success = false;
                return(response);
            }
            return(response);
        }
Exemplo n.º 2
0
        public RequestMessageFormat <UserCurrentRequestStatusDTO> Update(UserCurrentRequestStatusDTO userCurrentRequestStatusDTO)
        {
            RequestMessageFormat <UserCurrentRequestStatusDTO> response = new RequestMessageFormat <UserCurrentRequestStatusDTO>();

            try
            {
                userCurrentRequestStatusDTO.ModifiedOn = DateTime.Now;
                UserCurrentRequestStatus userCurrentRequestStatus = this.AutoMapperConfigurations.UserCurrentRequestStatusDTOToUserCurrentRequestStatus(userCurrentRequestStatusDTO);

                bool isUpdated = this.UserCurrentRequestStatusRepository.Update(userCurrentRequestStatus);
                if (isUpdated)
                {
                    response.Message = "Updated Successfully";
                    response.Data    = userCurrentRequestStatusDTO;
                    response.Success = true;
                    return(response);
                }
            }
            catch (Exception)
            {
                response.Message = "Some Error Occurred";
                response.Success = false;
                response.Data    = null;
                return(response);
            }
            return(response);
        }
Exemplo n.º 3
0
        //public RequestMessageFormat<List<UserCurrentRequestStatusDTO>> GetByStatus(string status)
        //{
        //    List<UserCurrentRequestStatus> userCurrentRequestStatusList = new List<UserCurrentRequestStatus>();
        //        if(status=="declined")
        //        {
        //        userCurrentRequestStatusList = this.UserCurrentRequestStatusRepository.List.Find((item) => item.UserRequestType == UserRequestStatusType.Pending);
        //    }
        //    else if(status=="pending")
        //        {

        //        }if(status=="approved")
        //        {

        //        }

        //    List<UserCurrentRequestStatusDTO> userCurrentRequestStatusDTOList = this.AutoMapperConfigurations.UserCurrentRequestStatusListToUserCurrentRequestStatusDTOList(userCurrentRequestStatusList);
        //    RequestMessageFormat<List<UserCurrentRequestStatusDTO>> response = new RequestMessageFormat<List<UserCurrentRequestStatusDTO>>();
        //    if (userCurrentRequestStatusList.Count == 0)
        //    {
        //        response.Data = null;
        //        response.Success = false;
        //        response.Message = "Empty List";
        //    }
        //    else
        //    {
        //        response.Data = userCurrentRequestStatusDTOList;
        //        response.Success = true;
        //        response.Message = "Data fetched successfully";
        //    }
        //    return response;
        //}

        public RequestMessageFormat <UserCurrentRequestStatusDTO> GetById(int id)
        {
            RequestMessageFormat <UserCurrentRequestStatusDTO> response = new RequestMessageFormat <UserCurrentRequestStatusDTO>();

            try
            {
                UserCurrentRequestStatus    userCurrentRequestStatus    = this.UserCurrentRequestStatusRepository.FindById(id);
                UserCurrentRequestStatusDTO userCurrentRequestStatusDTO = this.AutoMapperConfigurations.UserCurrentRequestStatusToUserCurrentRequestStatusDTO(userCurrentRequestStatus);

                if (userCurrentRequestStatus == null)
                {
                    response.Data    = null;
                    response.Success = false;
                    response.Message = "House Not Found";
                    return(response);
                }
                else
                {
                    response.Data    = userCurrentRequestStatusDTO;
                    response.Success = true;
                    response.Message = "Data fetched successfully";
                    return(response);
                }
            }
            catch (Exception)
            {
                response.Message = "Some Error Occurred while deleting data. Please try again";
                response.Success = false;
                response.Data    = null;
                return(response);
            }
        }
Exemplo n.º 4
0
        public RequestMessageFormat <UserCurrentRequestStatusDTO> Delete(int id)
        {
            RequestMessageFormat <UserCurrentRequestStatusDTO> response = new RequestMessageFormat <UserCurrentRequestStatusDTO>();

            try
            {
                UserCurrentRequestStatus userCurrentRequestStatus = this.UserCurrentRequestStatusRepository.FindById(id);


                if (userCurrentRequestStatus == null)
                {
                    response.Message = "House Not Exist";
                    response.Success = false;
                    response.Data    = null;
                    return(response);
                }
                else
                {
                    bool isDeleted = this.UserCurrentRequestStatusRepository.Delete(userCurrentRequestStatus);
                    if (isDeleted)
                    {
                        response.Message = "Deleted Successfully";
                        response.Success = true;
                        response.Data    = null;
                        return(response);
                    }
                }
            }catch (Exception)
            {
                response.Message = "Some Error Occurred while deleting data. Please try again";
                response.Success = false;
                response.Data    = null;
                return(response);
            }
            return(response);
        }
Exemplo n.º 5
0
 public UserCurrentRequestStatusDTO UserCurrentRequestStatusToUserCurrentRequestStatusDTO(UserCurrentRequestStatus userCurrentRequestStatus)
 {
     return(Mapper.Map <UserCurrentRequestStatusDTO>(userCurrentRequestStatus));
 }
        public RequestMessageFormat <LoginedUserDTO> LoginUser(LoginUserDTO loginUserDTO)
        {
            RequestMessageFormat <LoginedUserDTO> response = new RequestMessageFormat <LoginedUserDTO>();

            try
            {
                int count = this.UserRepository.Find(user => user.Email == loginUserDTO.Email).ToList().Count();

                if (count == 0)
                {
                    response.Data    = null;
                    response.Message = "No User found with this email";
                    response.Success = false;
                    return(response);
                }
                else
                {
                    count = 0;
                    count = this.UserRepository.Find(user => user.Email == loginUserDTO.Email && user.Password == loginUserDTO.Password).ToList().Count();
                    if (count != 0)
                    {
                        User user = this.UserRepository.Find(theuser => theuser.Email == loginUserDTO.Email).ToList().First();
                        if (user.IsApprover == BooleanType.True)
                        {
                            LoginedUserDTO loginedUserDTO1 = this.AutoMapperConfigurations.UserToLoginedUserDTO(user);
                            response.Data = loginedUserDTO1;

                            response.Message = "You are successfully loggedIn";
                            response.Success = true;
                            return(response);
                        }

                        LoginedUserDTO loginedUserDTO = this.AutoMapperConfigurations.UserToLoginedUserDTO(user);


                        UserCurrentRequestStatus userCurrentRequestStatus = this.UserCurrentRequestStatusRepository.Find(status => status.UserId == user.ID).ToList().First();
                        loginedUserDTO.UserRequestStatus = userCurrentRequestStatus.UserRequestType;


                        response.Data = loginedUserDTO;

                        response.Message = "You are successfully loggedIn";
                        response.Success = true;
                        return(response);
                    }
                    else
                    {
                        response.Data    = null;
                        response.Message = "Incorrect Password";
                        response.Success = false;
                        return(response);
                    }
                }
            }
            catch (Exception)
            {
                response.Message = "Some Error Occurred while adding data please try again";
                response.Data    = null;
                response.Success = false;
                return(response);
            }
        }
        public RequestMessageFormat <UserDTO> Add(UserDTO userDTO)
        {
            RequestMessageFormat <UserDTO> response = new RequestMessageFormat <UserDTO>();

            try
            {
                userDTO.CreatedOn  = DateTime.Now;
                userDTO.ModifiedOn = DateTime.Now;
                userDTO.IsApprover = BooleanType.False;

                if (this.CheckEmptyData(userDTO))
                {
                    response.Message = "Entered Invalid Data";
                    response.Data    = null;
                    response.Success = false;
                    return(response);
                }
                if (this.CheckDuplicateAadhar(userDTO))
                {
                    response.Message = "Aadhar Number Already Exists";
                    response.Data    = null;
                    response.Success = false;
                    return(response);
                }

                if (this.CheckDuplicateEmail(userDTO))
                {
                    response.Message = "Email Already Exists";
                    response.Data    = null;
                    response.Success = false;
                    return(response);
                }



                User user = this.AutoMapperConfigurations.UserDTOToUser(userDTO);
                bool isAdded;

                isAdded = this.UserRepository.Add(user);

                if (isAdded)
                {
                    response.Message = "Added Successfully";
                    userDTO.ID       = user.ID;
                    UserCurrentRequestStatus userCurrentRequestStatus = new UserCurrentRequestStatus();
                    userCurrentRequestStatus.UserId          = user.ID;
                    userCurrentRequestStatus.UserRequestType = UserRequestStatusType.Pending;
                    userCurrentRequestStatus.CreatedOn       = DateTime.Now;
                    userCurrentRequestStatus.ModifiedOn      = DateTime.Now;

                    this.UserCurrentRequestStatusRepository.Add(userCurrentRequestStatus);



                    response.Data    = userDTO;
                    response.Success = true;
                    return(response);
                }
            }
            catch (Exception)
            {
                response.Message = "Some Error Occurred while adding data please try again";
                response.Data    = null;
                response.Success = false;
                return(response);
            }
            return(response);
        }