Exemplo n.º 1
0
        public IHttpActionResult PutCompany(int id, Company company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != company.CompanyId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult PutMobileDevice(int id, MobileDevice mobileDevice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mobileDevice.MobileDeviceId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
 public bool Update(ProductType entity)
 {
     try
     {
         _context.Entry(entity).State = EntityState.Modified;
         _context.ProductTypes.Add(entity);
         Save();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 4
0
        //public bool Update(ProductFamily prodFam)
        //{
        //    Context.Entry(prodFam).State = EntityState.Modified;
        //    Context.ProductFamilys.Attach(prodFam);
        //    Context.SaveChanges();
        //    return true;
        //}

        public bool Delete(int id)
        {
            var prodFam = _context.ProductFamilys.FirstOrDefault(x => x.Id == id);

            if (prodFam != null)
            {
                _context.Entry(prodFam).State = EntityState.Modified;
                _context.ProductFamilys.Remove(prodFam);
                _context.SaveChanges();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 public bool Update(T entity)
 {
     _dbContext.Entry(entity).State = EntityState.Modified;
     Save();
     return(true);
 }