public async Task <bool> Post(Registration model) { var result = false; var emailExist = await _adminAccountBusiness.CheckEmailExist(model.Email); if (!emailExist) { return(result); } if (ModelState.IsValid) { model.Status = 1; model.CreatedDate = DateTime.Now; var modelInsert = await _registrationBusiness.Add(model); if (modelInsert) { string user = _appSetting.GetValue <string>("AppSettings:EmailAuthentication:UserName"); string password = _appSetting.GetValue <string>("AppSettings:EmailAuthentication:Password"); await _emailBusiness.SendEmailToOwnerAfterRegister(model, user, password); } result = modelInsert; } return(result); }
public async Task <int> Post(AdminAccount model) { string user = _appSetting.GetValue <string>("AppSettings:EmailAuthentication:UserName"); string password = _appSetting.GetValue <string>("AppSettings:EmailAuthentication:Password"); string activeUrl = _appSetting.GetValue <string>("AppSettings:ActiveUrl"); //restaurant owner create account if (_authenticationDto.RestaurantId > 0) { model.RestaurantId = _authenticationDto.RestaurantId; } var result = 0; if (ModelState.IsValid) { var dateTimeUtcNow = DateTime.Now; model.PasswordHash = WebsiteExtension.EncryptPassword(model.PasswordHash); model.CreatedStaffId = _authenticationDto.UserId; model.CreatedDate = dateTimeUtcNow; model.Status = 1; model.Active = 0; //recheck eamil and username is existed if (!await _adminAccountBusiness.CheckEmailExist(model.Email) || !await _adminAccountBusiness.CheckUserNameExist(model.UserName)) { return(result); } var modelInsert = await _adminAccountBusiness.Add(model); result = modelInsert.Id; if (result > 0) { await _emailBusiness.SendEmailToActiveAccount(modelInsert, user, password, activeUrl); } } return(result); }