Ejemplo n.º 1
0
        public HttpResponseMessage Delete(int id)
        {
            Spartan_User_Most_Used_Object varSpartan_User_Most_Used_Object = this.service.GetByKey(id, false);
            bool result = false;

            if (varSpartan_User_Most_Used_Object == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
            }
            catch (ServiceException ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Put(int id, Spartan_User_Most_Used_Object varSpartan_User_Most_Used_Object)
        {
            if (ModelState.IsValid && id == varSpartan_User_Most_Used_Object.User_Most_Used_Object_Id)
            {
                var data = -1;
                try
                {
                    data = this.service.Update(varSpartan_User_Most_Used_Object);//, globalData, dataReference);
                }
                catch (ServiceException ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors).Select(error => error.ErrorMessage);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }