예제 #1
0
 public IActionResult CreateOrchid([FromBody] OrchidNew newobj) //Create New Orchid
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     if (newobj == null)
     {
         return(BadRequest());
     }
     _orchidnewRepo.CreateOrchid(newobj);
     return(NoContent());
 }
예제 #2
0
        [HttpPut("{id}")] //Update Method
        public IActionResult UpdateOrchid(int ID, [FromBody] OrchidNew newobj)
        {
            if (ID < 0)
            {
                return(BadRequest());
            }
            int result = _orchidnewRepo.UpdateOrchid(ID, newobj);

            if (result == 0)
            {
                return(BadRequest());
            }
            else
            {
                return(Ok());
            }
        }
예제 #3
0
        public int UpdateOrchid(int ID, OrchidNew orchidObject)
        {
            var orchids = _myDbContext.OrchidNews.Where(c => c.orchidID == ID).SingleOrDefault();

            if (orchids == null)
            {
                return(0);
            }
            else
            {
                orchids.orchidName = orchidObject.orchidName;
                orchids.category   = orchidObject.category;
                orchids.size       = orchidObject.size;
                orchids.price      = orchidObject.price;
                orchids.quanity    = orchidObject.quanity;
                orchids.manuDate   = orchidObject.manuDate;
                orchids.expTime    = orchidObject.expTime;
                _myDbContext.SaveChanges();
                return(1); //If Success Return One.
            }
        }
예제 #4
0
 public void CreateOrchid(OrchidNew orchidObject) //enter a new data packet
 {
     _myDbContext.OrchidNews.Add(orchidObject);
     _myDbContext.SaveChanges();
 }