public string Register(RegisterDTO _accountDao) { try { objRegisterDB.CreateNewUser(_accountDao.UserName, _accountDao.UserPassword, _accountDao.Email); } catch (Exception ex) { throw ex; } return(code); }
public HttpResponseMessage CreateUserExpose(MemberViewModel objUser) { StatusReturn objReturn = null; string strReturn = null; try { CreateMemberValidation objCreateMembershipValidation = new CreateMemberValidation(); ApplicationUser objApplicationUser = UserRepository.MapToApplicationUser(objUser); if (ApiUserSessionRepository.IsAuthorize(objUser.SessionId)) { objCreateMembershipValidation.CheckValidation(objUser); if (!objCreateMembershipValidation.IsNotValidate) { var retResult = UserRepository.CreateWifiUser(objApplicationUser); if (retResult == RepositoryResult.Success) { retResult = UserRepository.CreateUserRole(objApplicationUser); if (retResult == RepositoryResult.Success) { RegisterDB objRegisterDB = new RegisterDB(); objRegisterDB.CreateNewUser(objUser.UserName, objUser.Password, objUser.Email, objUser.FirstName, objUser.LastName); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Success), ReturnCode.Success.ToString(), Common.Common.Reg_Success); strReturn = JsonConvert.SerializeObject(objReturn); } } } else { strReturn = JsonConvert.SerializeObject(objCreateMembershipValidation.listStatusReturn); } } else { objReturn = new StatusReturn(Convert.ToInt32(ErrorCodeWarning.NonAuthorize), ReturnCode.Warning.ToString(), "Invalid SessionId"); strReturn = JsonConvert.SerializeObject(objReturn); } } catch (Exception ex) { //dbContextTransaction.Rollback(); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Success.ToString(), Common.Common.Reg_Success); strReturn = JsonConvert.SerializeObject(objReturn); } return(new HttpResponseMessage() { Content = new StringContent(strReturn, Encoding.UTF8, "application/json") }); }
public HttpResponseMessage Register(RegisterViewModel objRegisterModel) { using (var dbContextTransaction = db.Database.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted)) { try { Log.Info("enter in register"); UserInfo _objUserInfo = new UserInfo(); _objUserInfo.company_id = objRegisterModel.company_id; _objUserInfo.email = objRegisterModel.Email; _objUserInfo.password = objRegisterModel.UserPassword; _objUserInfo.username = objRegisterModel.UserName; db.UserInfoModels.Add(_objUserInfo); db.SaveChanges(); objRegisterDB.CreateNewUser(objRegisterModel.UserName, objRegisterModel.UserPassword, objRegisterModel.Email); ObjReturnModel.Id = 1; ObjReturnModel.Message = "Sucess"; dbContextTransaction.Commit(); UserRole objUserRole = new UserRole(); var user = db.UserInfoModels.Where(i => i.email == objRegisterModel.Email).FirstOrDefault(); objUserRole.id = user.id; var role = db.Roles.Where(i => i.RoleName == "User").FirstOrDefault(); objUserRole.RoleId = role.RoleId; db.UserRoles.Add(objUserRole); db.SaveChanges(); JavaScriptSerializer objSerializer = new JavaScriptSerializer(); return(new HttpResponseMessage { Content = new StringContent(objSerializer.Serialize(ObjReturnModel)) }); } catch (Exception ex) { Log.Error(ex.Message); dbContextTransaction.Rollback(); throw ex; } } }