예제 #1
0
        public int Insert(Spartan_Notice entity, GlobalData UserInformation, Core.Domain.Data.DataLayerFieldsBitacora DataReference)
        {
            entity.NoticeId = list.Last().NoticeId++;
            list.Add(entity);

            return(entity.NoticeId);
        }
예제 #2
0
        public int Update(Spartan_Notice entity, GlobalData UserInformation, Core.Domain.Data.DataLayerFieldsBitacora DataReference)
        {
            var user = list.SingleOrDefault(v => v.NoticeId == entity.NoticeId);

            list.Remove(user);
            list.Add(entity);

            return(list.Count);
        }
예제 #3
0
        public HttpResponseMessage Delete(int id)
        {
            Spartan_Notice varSpartan_Notice = this.service.GetByKey(id, false);
            bool           result            = false;

            if (varSpartan_Notice == 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));
        }
예제 #4
0
        public HttpResponseMessage Put(int id, Spartan_Notice varSpartan_Notice)
        {
            if (ModelState.IsValid && id == varSpartan_Notice.Notice_Id)
            {
                var data = -1;
                try
                {
                    data = this.service.Update(varSpartan_Notice);//, 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));
            }
        }