public async Task <IActionResult> UpdateHouse(CreateOrUpdateHouseInput input) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); if (user != null) { var myHouse = db.Houses.FirstOrDefault(x => x.Id == input.Id); myHouse.Name = input.Name; myHouse.Address = input.Address; db.Update(myHouse); await db.SaveChangesAsync(); return(Ok(new { Succeeded = "Success" })); } return(BadRequest()); }
public async Task <IActionResult> CreateHouse(CreateOrUpdateHouseInput input) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); if (user != null) { House myHouse = new House { LandlordsId = user.Id, Address = input.Address, Name = input.Name }; await db.AddAsync(myHouse); await db.SaveChangesAsync(); return(Ok(new { Succeeded = "Success" })); } return(BadRequest()); }