Пример #1
0
 public ActionResult Post([FromBody] LiteWidgetDTO value)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (value == null)
     {
         return(BadRequest());
     }
     repoWrapper.Widget.Insert(mapper.Map <Widget>(value));
     repoWrapper.Save();
     return(Ok());
 }
Пример #2
0
        public ActionResult Put(long id, [FromBody] LiteWidgetDTO value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != value.Id)
            {
                return(BadRequest("Value with the given id doesn't exist."));
            }
            var entity = repoWrapper.Widget.Get(id);

            if (entity == null)
            {
                return(BadRequest("Value with the given id is null"));
            }
            mapper.Map(value, entity);
            repoWrapper.Save();
            return(Ok());
        }