public IHttpActionResult PutTypeCode(int id, JobsInABA.DAL.Entities.TypeCode typeCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != typeCode.TypeCodeID)
            {
                return(BadRequest());
            }

            db.Entry(typeCode).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeCodeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetTypeCode(int id)
        {
            JobsInABA.DAL.Entities.TypeCode typeCode = db.TypeCodes.Find(id);
            if (typeCode == null)
            {
                return(NotFound());
            }

            return(Ok(typeCode));
        }
Пример #3
0
        public IHttpActionResult DeletetypeCode(int id)
        {
            JobsInABA.DAL.Entities.TypeCode typeCode = db.TypeCodes.Find(id);
            if (typeCode == null)
            {
                return(NotFound());
            }

            db.TypeCodes.Remove(typeCode);
            db.SaveChanges();

            return(Ok(typeCode));
        }
Пример #4
0
        public IHttpActionResult PostTypeCode(JobsInABA.DAL.Entities.TypeCode typeCode)
        {
            //typeCode = new JobsInABA.DAL.Entities.TypeCode();
            //typeCode.ClassTypeID = 4;
            //typeCode.Code = "TEST1";
            //typeCode.Description = "Created 3_5_2016";
            //typeCode.Name = "Main";
            ////typeCode.TypeCodeID = 1;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TypeCodes.Add(typeCode);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = typeCode.TypeCodeID }, typeCode));
        }
        public IHttpActionResult PostTypeCode(JobsInABA.DAL.Entities.TypeCode typeCode)
        {
            typeCode             = new JobsInABA.DAL.Entities.TypeCode();
            typeCode.ClassTypeID = 1;
            typeCode.Code        = "p";
            typeCode.Description = "NA";
            typeCode.Name        = "primary";
            typeCode.TypeCodeID  = 1;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TypeCodes.Add(typeCode);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = typeCode.TypeCodeID }, typeCode));
        }
Пример #6
0
        public IHttpActionResult PutTypeCode(int id, JobsInABA.DAL.Entities.TypeCode typeCode)
        {
            //typeCode = new JobsInABA.DAL.Entities.TypeCode();
            //typeCode.ClassTypeID = 4;
            //typeCode.Code = "BS";
            //typeCode.Description = "Business Code";
            //typeCode.Name = "Business primary";
            //typeCode.TypeCodeID = id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != typeCode.TypeCodeID)
            {
                return(BadRequest());
            }

            db.Entry(typeCode).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeCodeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }