コード例 #1
0
        //AddNote allows user to add a note to a plant on MyPlant list. It takes MyPlantID and adds note to plant that matches with MyPlantID.
        public bool AddNote(AddNotesToMyPlant model)
        {
            MyPlants myPlants = ctx.MyPlants.Single(e => e.MyPlantID == model.MyPlantID);

            if (myPlants.UserID != _userID)
            {
                return(false);
            }
            myPlants.Notes = model.Notes;
            return(ctx.SaveChanges() == 1);
        }
コード例 #2
0
        public IHttpActionResult AddNote(AddNotesToMyPlant addNotes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateMyPlantService();

            if (!service.AddNote(addNotes))
            {
                return(InternalServerError());
            }
            return(Ok());
        }