Exemple #1
0
        public IHttpActionResult PutIN_ProductRequis(int id, IN_ProductRequis iN_ProductRequis)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != iN_ProductRequis.RequisID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult GetIN_ProductRequis(int id)
        {
            string username    = Thread.CurrentPrincipal.Identity.Name;
            string getUsername = username.ToLower();
            var    checkAdmin  = db.IN_ProductRequis.Where(e => e.UserID.ToLower() == getUsername && e.RequisID == id).ToList();

            if (!CheckPermission())
            {
                IN_ProductRequis iN_ProductRequis = db.IN_ProductRequis.Find(id);
                if (iN_ProductRequis == null)
                {
                    return(NotFound());
                }

                return(Ok(iN_ProductRequis));
            }
            else
            {
                if (checkAdmin.Count() != 0)
                {
                    IN_ProductRequis iN_ProductRequis = db.IN_ProductRequis.Find(id);
                    if (iN_ProductRequis == null)
                    {
                        return(NotFound());
                    }

                    return(Ok(iN_ProductRequis));
                }
                else
                {
                    return(NotFound());
                }
            }
        }
Exemple #3
0
        public IHttpActionResult PostIN_ProductRequis(IN_ProductRequis iN_ProductRequis)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.IN_ProductRequis.Add(iN_ProductRequis);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = iN_ProductRequis.RequisID }, iN_ProductRequis));
        }
Exemple #4
0
        public IHttpActionResult DeleteIN_ProductRequis(int id)
        {
            IN_ProductRequis iN_ProductRequis = db.IN_ProductRequis.Find(id);

            if (iN_ProductRequis == null)
            {
                return(NotFound());
            }

            db.IN_ProductRequis.Remove(iN_ProductRequis);
            db.SaveChanges();

            return(Ok(iN_ProductRequis));
        }