public async void Register(UserRegistrationModel registerUser) { var user = new User(registerUser.Email, registerUser.Location, registerUser.Web, registerUser.Bio, registerUser.UserId); await _userDbContext.AddAsync(user); await _userDbContext.SaveChangesAsync(); }
public async Task <IResult> Add(Users user) { try { if (user == null) { return(await Task.FromResult(Result.Fail("topic null"))); } await _dbContext.AddAsync(user); int result = await _dbContext.SaveChangesAsync();; if (result >= 0) { return(await Task.FromResult(Result.Success())); } else { return(await Task.FromResult(Result.Fail("Not add"))); } } catch (Exception ex) { return(await Task.FromResult(Result.Fail("Not add"))); } //throw new NotImplementedException(); }
public async Task <User> Add(User user) { await userDbContext.AddAsync(user); await userDbContext.SaveChangesAsync(); return(user); }
public async Task Create(T entity) { if (entity != null) { await _context.AddAsync(entity); await _context.SaveChangesAsync(); } }
public async Task <ActionResult <GeoMessagev1DTO> > CreateNewPostAsync(GeoMessagev1DTO DTO) { var geoMessagePost = new GeoMessage { Longitude = DTO.longitude, Latitude = DTO.latitude, Body = DTO.Message, }; var GeoMessageV1DTOresponse = PostGeoMessageToDTOV1(geoMessagePost); await _context.AddAsync(geoMessagePost); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetMessagev2), new { id = geoMessagePost.Id }, GeoMessageV1DTOresponse)); }
public async Task <IActionResult> OnPost() { if (ModelState.IsValid) { RSVPUser user = new RSVPUser() { Agree = Agree, Name = Name, Email = Email, PhoneNumber = PhoneNumber, IsVeteran = IsVeteran, PreferredTime = PreferredTime, IsWashingtonResident = IsWashingtonResident, ChooseMaritalStatus = ChooseMaritalStatus, SpouseName = SpouseName, HasChildren = HasChildren, IsCurrentlyPregnant = IsCurrentlyPregnant, MinorChildName = MinorChildName, ContRemBeneficiary = ContRemBeneficiary, PersonToInherit = PersonToInherit, PersonalRep = PersonalRep, //BackupRep = BackupRep, }; //if (PersonalRep == BackupRep) //{ // TempData["Error"] = "Please make sure your Personal Rep is not the same as your Backup Rep."; // return Page(); //} if (!Agree) { TempData["Error"] = "You cannot sign up unless you agree to the terms and conditions."; return(Page()); } await _context.AddAsync(user); await _context.SaveChangesAsync(); await _emailSender.SendEmailAsync(Email, EmailMessages.Thanks, EmailMessages.SignUpReply(user)); return(RedirectToPage("/")); } return(Page()); }
public async Task <int> CheckOrCreate(CreateUserInput input) { var isExsit = await _dbContext.UserInfo.AnyAsync(p => p.Phone == input.Phone); if (isExsit) { var idresult = await _dbContext.UserInfo.FirstOrDefaultAsync(p => p.Phone == input.Phone); return(idresult.Id); } else { UserInfo userinfo = new UserInfo(); userinfo.Phone = input.Phone; await _dbContext.AddAsync(userinfo); var result = await _dbContext.SaveChangesAsync(); return(result); } }
public async Task <bool> AddUser(User user) { try { var country = await _db.Country.SingleOrDefaultAsync((c) => c.CountryId == user.Country.CountryId); if (country is null) { return(false); } user.Country = country; await _db.AddAsync(user); await _db.SaveChangesAsync(); return(true); } catch (Exception) { throw; } }