Ejemplo n.º 1
0
        public async Task <ActionResult <CommonAPIResponse <bool> > > AddAdmin(AdminAddDTO AdminAddDTO)
        {
            #region Declare return type with initial value.
            JsonResult jsonResult = GetDefaultJsonResult <bool>();
            #endregion

            try
            {
                #region Validate AddAdmin for nullability before prepaing the response.

                if (await AdminAppService.AddAdmin(AdminAddDTO))
                {
                    jsonResult = JsonResultResponse(CommonHelper.GetResponseMessage(APIResponseMessage.Success, CurrentLanguagId), true, HttpStatusCode.OK);
                }
                else
                {
                    jsonResult = JsonResultResponse(CommonHelper.GetResponseMessage(APIResponseMessage.InvalidCredentials, CurrentLanguagId), false, HttpStatusCode.BadRequest);
                }
                #endregion
            }
            catch (Exception exception)
            {
            }
            return(jsonResult);
        }
 /// <summary>
 /// Add Admin AppService
 /// </summary>
 /// <returns>bool<bool></returns>
 public async Task <bool> AddAdmin(AdminAddDTO adminAddDTO)
 {
     #region Declare a return type with initial value.
     bool isCreated = false;
     #endregion
     try
     {
         if (adminAddDTO != null)
         {
             isCreated = await AdminBusinessMapping.AddAdmin(adminAddDTO);
         }
     }
     catch (Exception exception) {}
     return(isCreated);
 }
 /// <summary>
 /// Create User
 /// </summary>
 /// <param name="createUserInputDTO"></param>
 /// <returns>bool</returns>
 public async Task <bool> AddAdmin(AdminAddDTO adminAddDTO)
 {
     #region Declare a return type with initial value.
     bool isUserCreated = default(bool);
     #endregion
     try
     {
         #region Vars
         UserPasswordDTO userPasswordDTO = null;
         Admin           admin           = null;
         #endregion
         #region Check user email not exsist
         if (!await IsEmailExist(adminAddDTO.Email))
         {
             #region Create Hash Passowrd using password string
             userPasswordDTO = CreatePasswordHash(adminAddDTO.Password);
             #endregion
             #region Check if user password DTO not equal null
             if (userPasswordDTO != null)
             {
                 #region Mapp user Add DTO and User Password DTO to User entity model
                 admin = AdminMapping.MappingAdminAddDTOToAdmin(adminAddDTO, userPasswordDTO);
                 #endregion
                 #region Check if user not equal null
                 if (admin != null)
                 {
                     #region insert user enity model to user repository
                     if (await UnitOfWork.AdminRepository.Insert(admin))
                     {
                         isUserCreated = await UnitOfWork.Commit() > default(int);
                     }
                     #endregion
                 }
                 #endregion
             }
             #endregion
         }
         #endregion
     }
     catch (Exception exception)
     {
         //Logger.Instance.LogException(exception, LogLevel.Medium);
     }
     return(isUserCreated);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Mapping user Action Actitvity Log
 /// </summary>
 /// <param name=></ param >
 /// <returns>Task<Admin></returns>
 public Admin MappingAdminAddDTOToAdmin(AdminAddDTO AdminAddDTO, UserPasswordDTO userPasswordDTO)
 {
     #region Declare a return type with initial value.
     Admin Admin = null;
     #endregion
     try
     {
         Admin = new Admin
         {
             FullName     = AdminAddDTO.FullName,
             Address      = AdminAddDTO.Address,
             Phone        = AdminAddDTO.Phone,
             Email        = AdminAddDTO.Email,
             PasswordHash = userPasswordDTO.PasswordHash,
             PasswordSalt = userPasswordDTO.PasswordSalt,
             CreationDate = DateTime.Now,
             IsDeleted    = (byte)DeleteStatusEnum.NotDeleted
         };
     }
     catch (Exception exception) { }
     return(Admin);
 }