public async Task <UserBo> Registration(RegisterBo entity) { try { string userId = Guid.NewGuid().ToString(); var auth = new Authentication { Active = false, Email = entity.Email.Trim().ToLower(), IsValiedEmail = false, Password = entity.Password, RegDate = DateTime.UtcNow, Roles = Bo.Utility.Enums.Roles.User, UserId = userId }; this.uow.Context.Authentications.Add(auth); await this.uow.SaveAsync(); return(Mapper.Map <UserBo>(auth)); } catch (Exception ex) { throw HandleException(ex); } }
public ResponseDto Register(RegisterDto registerDto) { //if (registerDto.Password != registerDto.RePassword) //{ // return new ResponseDto() // { // IsSuccess = false, // Message = Business.Stc.GetDicValue("xPasswordNotMatch", registerDto.LanguageId) // }; //} RegisterBo registerBo = new RegisterBo { Name = registerDto.Name, Surname = registerDto.Surname, Password = registerDto.Password, Username = registerDto.Username, LanguageId = registerDto.LanguageId, GenderId = registerDto.GenderId, Birthdate = registerDto.BirthdateNumber.ToDateTimeFromNumberNull(), HaveShopToo = registerDto.HaveShopToo, ShopShortName = registerDto.ShopShortName, ShopTypeId = registerDto.ShopTypeId }; return(authBusiness.Register(registerBo).ToResponseDto()); }
public ResponseBo Register(RegisterBo registerBo) { ResponseBo responseBo = new ResponseBo(); try { Enums.Languages langId = registerBo.LanguageId; #region Checks if (registerBo == null) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xInvalidData", langId); return(responseBo); } if (registerBo.Username.IsNull()) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xEmailCantBeEmpty", langId); return(responseBo); } if (registerBo.Name.IsNull()) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xFirstNameCantBeEmpty", langId); return(responseBo); } if (registerBo.Surname.IsNull()) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xLastNameCantBeEmpty", langId); return(responseBo); } if (registerBo.Password.IsNull()) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xPasswordCantBeEmpty", langId); return(responseBo); } if (Validation.ValidateEmail(registerBo.Username) == false) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xEnterValidMailAddress", langId); return(responseBo); } if (registerBo.HaveShopToo && registerBo.ShopShortName.IsNull()) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xShopSignNameCantBeEmpty", langId); return(responseBo); } if (registerBo.HaveShopToo && registerBo.ShopTypeId.IsNull()) { responseBo.IsSuccess = false; responseBo.Message = GetDicValue("xSelectShopType", langId); return(responseBo); } #endregion // we may change it later. // but username equals to email. registerBo.Email = registerBo.Username; using (SqlConnection conn = DbAccess.Connection.GetConn()) { var p = new DynamicParameters(); p.Add("@Id", dbType: DbType.Int64, direction: ParameterDirection.Output); p.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 255); p.Add("@IsSuccess", dbType: DbType.Boolean, direction: ParameterDirection.Output); p.Add("@Name", registerBo.Name, DbType.String, ParameterDirection.Input, 50); p.Add("@Surname ", registerBo.Surname, DbType.String, ParameterDirection.Input, 50); p.Add("@Username", registerBo.Username, DbType.String, ParameterDirection.Input, 250); p.Add("@Password", registerBo.Password, DbType.String, ParameterDirection.Input, 250); p.Add("@Email", registerBo.Email, DbType.String, ParameterDirection.Input, 250); p.Add("@LanguageId", registerBo.LanguageId, DbType.Int32, ParameterDirection.Input); p.Add("@GenderId", registerBo.GenderId, DbType.Int32, ParameterDirection.Input); p.Add("@Birthdate", registerBo.Birthdate, DbType.Date, ParameterDirection.Input); p.Add("@HaveShopToo", registerBo.HaveShopToo, DbType.Boolean, ParameterDirection.Input); p.Add("@ShopShortName", registerBo.ShopShortName, DbType.String, ParameterDirection.Input, 255); p.Add("@ShopTypeId", registerBo.ShopTypeId, DbType.Int32, ParameterDirection.Input); var user = conn.Execute("spAuthRegister", p, commandType: CommandType.StoredProcedure); responseBo.ReturnedId = p.Get <long?>("@Id"); responseBo.Message = p.Get <string>("@Message"); responseBo.IsSuccess = p.Get <bool>("@IsSuccess"); } } catch (Exception ex) { responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, null); } return(responseBo); }