public ActionResult <User> AssignUserNeed(string uid, [FromRouteAttribute] string nid) { var UserCheck = _userService.GetUser(uid); if (UserCheck == null) { return(NotFound()); } ObjectId nidy = new ObjectId(nid); List <Need> ListOfAssigned = new List <Need>(); UserCheck.NeedsIds.ForEach(uid => { var need = _needService.GetNeed(uid.ToString()); ListOfAssigned.Add(need); } ); var NeedGet = _needService.GetNeed(nid); NeedGet.State = Utils.Utils.NEED_STATE_ASSIGNED; if (NeedGet == null) { return(NotFound()); } UserCheck.NeedsIds.Add(nidy); _needService.UpdateNeed(nid, NeedGet); _userService.AssignUserNeed(uid, nidy, UserCheck); return(NoContent()); }
public ActionResult <Need> UpdateNeed(string id, [FromBody] Need need) { var NeedCheck = _needsService.GetNeed(id); if (NeedCheck == null) { return(NotFound()); } need.Id = id; need.UserId = NeedCheck.UserId; need.Date = NeedCheck.Date; need.State = NeedCheck.State; _needsService.UpdateNeed(id, need); return(NoContent()); }