public async Task <IActionResult> CheckTravelItem(CheckItemDTO checkItem) { //Check if the user is authenticated if (User.Identity.IsAuthenticated) { var useraccount = await this._userManager.FindByNameAsync(User.Identity.Name); Traveler traveler = this._travelerRepository.getTraveler(useraccount); Travel travel = traveler.Travels.FirstOrDefault(e => e.Id == checkItem.TravelId); if (travel != null) { TravelItem travelItem = this._travelItemRepository.getTravelItemOnTravelId(checkItem.TravelId).FirstOrDefault(e => e.Item.Id == checkItem.ItemId); if (travelItem != null) { travelItem.Checked = checkItem.Completed; this._travelItemRepository.updateItem(travelItem); this._travelItemRepository.SaveChanges(); return(Ok()); } return(NoContent()); } return(NoContent()); } return(Unauthorized()); }
public ActionResult PostCheckListItem(string checkListId, [FromBody] CheckItemDTO model) { try { var result = card_repo_.AddCheckListItem(checkListId, model); return(this.Ok(result)); } catch (Exception) { throw; } }
public ActionResult CheckItem([FromBody] CheckItemDTO model) { try { card_repo_.CheckItem(model); return(this.Ok()); } catch (Exception) { throw; } }
internal CheckItemDTO AddCheckListItem(string chekListId, CheckItemDTO model) { var ciModel = new CheckItemModel { Checked = false, Value = model.Value, }; db_.GetCollection <CheckItemModel>("CheckItem").InsertOne(ciModel); model.ID = ciModel.Id.ToString(); var filter = Builders <CheckListModel> .Filter.Eq("_id", new ObjectId(chekListId)); var update = Builders <CheckListModel> .Update.Push(clm => clm.CheckItems, ciModel.Id); db_.GetCollection <CheckListModel>("CheckLists").UpdateOne(filter, update); return(model); }
internal void CheckListItem(CheckItemDTO model) { UpdateField <bool, CheckItemModel>(model.ID, "Checked", model.Checked, "CheckItem"); }
public void CheckItem(CheckItemDTO model) { db_.CheckListItem(model); }
public CheckItemDTO AddCheckListItem(string id, CheckItemDTO model) { var result = db_.AddCheckListItem(id, model); return(result); }