public async Task<tbProfile> CreateNewUser(UserProfile user) { tbProfile profile = new tbProfile(); try { UserProfileDetails userProfile = new UserProfileDetails(); userProfile.UserId = Guid.NewGuid(); userProfile.Email = user.Email; userProfile.Password = user.Password; userProfile.CreatedTime = DateTime.UtcNow; userProfile.IsDeleted = false; userProfile.Credits = 0; profile = userProfile.ConvertToTbProfile(); _db.tbProfiles.Add(profile); await _db.SaveChangesAsync(); } catch (DataException dex) { throw new ApplicationException("Data error!", dex); } return profile; }
public async Task<UserProfileDetails> GetUserProfileByEmail(string email) { UserProfileDetails userPro = new UserProfileDetails(); try { var profile = await _reposTohowDev.GetTbProfileByEmail(email); if (profile != null) userPro = profile.ConvertToUserProfile(); else return null; } catch (Exception ex) { throw new ApplicationException("Error retriving User Profile", ex); } return userPro; }
public async Task CreateNewSession(UserProfileDetails userPro, string IPAddress) { try { tbSession ses = new tbSession(); ses.Id = Guid.NewGuid(); ses.CreateDateTime = DateTime.UtcNow; ses.Expiry = DateTime.UtcNow.AddDays(1); ses.ProfileId = userPro.ProfileId; ses.IPAddress = IPAddress; _db.tbSessions.Add(ses); await _db.SaveChangesAsync(); } catch (DataException dex) { throw new ApplicationException("Data error!", dex); } }
public async Task<UserProfileDetails> CreateNewUserProfile(UserProfile req) { UserProfileDetails userPro = new UserProfileDetails(); try { var user = await _reposTohowDev.CreateNewUser(req); userPro = user.ConvertToUserProfile(); } catch (Exception ex) { throw new ApplicationException("Error register new user", ex); } return userPro; }