public HttpResponseMessage Put([FromBody] PresentDay value)
        {
            if (ModelState.IsValid)
            {
                return((LogicPresentDay.UpdatePresent(value)) ?
                       new HttpResponseMessage(HttpStatusCode.OK) :
                       new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
                });
            }
            ;

            List <string> ErrorList = new List <string>();

            //if the code reached this part - the user is not valid
            foreach (var item in ModelState.Values)
            {
                foreach (var err in item.Errors)
                {
                    ErrorList.Add(err.ErrorMessage);
                }
            }

            return(new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new ObjectContent <List <string> >(ErrorList, new JsonMediaTypeFormatter())
            });
        }
 public HttpResponseMessage Put([FromBody] PresentDay value)
 {
     if (ModelState.IsValid)
     {
         return((LogicPresentDay.UpdatePresent(value)) ?
                new HttpResponseMessage(HttpStatusCode.OK) :
                new HttpResponseMessage(HttpStatusCode.BadRequest)
         {
             Content = new ObjectContent <String>("Can not update in DB", new JsonMediaTypeFormatter())
         });
     }
     ;
     return(Request.CreateResponse(HttpStatusCode.BadRequest, BaseLogic.GetErorList(ModelState.Values)));
 }
Пример #3
0
        public HttpResponseMessage UpdatePresentDay([FromBody] PresentDay value)
        {
            if (ModelState.IsValid)
            {
                return(LogicPresentDay.UpdatePresent(value) ?
                       Request.CreateResponse(HttpStatusCode.OK) :
                       Request.CreateResponse(HttpStatusCode.BadRequest, "Can not update in DB"));
            }
            ;

            List <string> ErrorList = new List <string>();

            //if the code reached this part - the user is not valid
            foreach (var item in ModelState.Values)
            {
                foreach (var err in item.Errors)
                {
                    ErrorList.Add(err.ErrorMessage);
                }
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest, ErrorList));
        }