Exemplo n.º 1
0
        public DataModel.StatusEntity GetStatusById(int id)
        {
            var data = db.Status.FirstOrDefault(c => c.StatusId == id);
            if (data != null)
            {
                StatusEntity status = new StatusEntity();
                status.StatusId = data.StatusId;
                status.Description = data.Description;

                return status;
            }
            return null;
        }
Exemplo n.º 2
0
        public IEnumerable<DataModel.StatusEntity> GetAll()
        {
            List<StatusEntity> statuses = new List<StatusEntity>();

            foreach (var data in db.Status)
            {
                StatusEntity status = new StatusEntity();
                status.StatusId = data.StatusId;
                status.Description = data.Description;

                statuses.Add(status);
            }

            return statuses;
        }
        // POST api/Status
        public HttpResponseMessage PostStatus(StatusEntity status)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
            if (status == null)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            try
            {
                dbContext.AddStatus(status);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }