public async Task <IHttpActionResult> PutFriendModel(int id, FriendModel friendModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != friendModel.Id) { return(BadRequest()); } db.Entry(friendModel).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FriendModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutTodoItem(long id, FriendsContext friends) { if (id != friends.id) { return(BadRequest()); } _context.Entry(friends).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> Register([FromBody] JObject user) { var getUser = await _dbContext.User.Where(x => x.Name == (string)user["user_name"] && x.Password == (string)user["password"]).SingleOrDefaultAsync(); if (getUser == null) { User addUser = new User(); addUser.NameSurename = (string)user["name_surename"]; addUser.Name = (string)user["user_name"]; addUser.Password = (string)user["password"]; addUser.UserId = 0; _dbContext.User.Add(addUser); await _dbContext.SaveChangesAsync(); return(Ok(addUser.Id)); } return(Ok(false)); }