public bool UpdateStatus(int id, bool status) { PropModified <Promotion> modified = new PropModified <Promotion>(new { Status = status }); using (var db = new EntityDAO <Promotion>(_context)) return(db.Update(id, modified)); }
public bool UpdateDTO(int id, PromotionDTO promotionDTO, string promDetail) { var prom = ObjectMapperTo <PromotionDTO, Promotion>(promotionDTO); PropModified <Promotion> modifiedProm = new PropModified <Promotion>(prom); int typeItem; using (var db = new EntityDAO <Promotion>(_context)) { var obj = db.Get(id); if (obj == null) { return(false); } typeItem = (int)obj.Type; if (!db.Update(id, modifiedProm)) { return(false); } } switch (typeItem) { case 1: { var promProduct = DataHelper.ParserJsonTo <PromProduct>(promDetail); PropModified <PromProduct> modifiedProduct = new PropModified <PromProduct>(promProduct); if (modifiedProduct.isChanged) { using (var db = new EntityDAO <PromProduct>(_context)) if (!db.Update(id, modifiedProduct)) { return(false); } } break; } case 2: { var promBill = DataHelper.ParserJsonTo <PromBill>(promDetail); PropModified <PromBill> modifiedBill = new PropModified <PromBill>(promBill); if (modifiedBill.isChanged) { using (var db = new EntityDAO <PromBill>(_context)) if (!db.Update(id, modifiedBill)) { return(false); } } break; } default: return(false); } return(true); }
public bool RemoveAttrDTO(string productId) { if (DataHelper.IsEmptyString(productId)) { return(false); } PropModified <Product> modified = new PropModified <Product>(new { isDel = true }); using (ProductDAO db = new ProductDAO(_context)) return(db.Update(productId, modified)); }
public bool UpdateStatusAttrDTO(string productId, bool status) { if (DataHelper.IsEmptyString(productId)) { return(false); } PropModified <Product> modified = new PropModified <Product>(new { isShow = status }); using (ProductDAO db = new ProductDAO(_context)) return(db.Update(productId, modified)); }
public bool UpdateAttrDTO(string productId, ProductDTO productDTO) { if (DataHelper.IsEmptyString(productId)) { return(false); } string[] ignore = { "productId", "isShow" }; PropModified <Product> modified = new PropModified <Product>(productDTO, ignore); using (ProductDAO db = new ProductDAO(_context)) return(db.Update(productId, modified)); }
public bool RemoveDTO(string productId) { if (DataHelper.IsEmptyString(productId)) { return(false); } var detailId = DataHelper.GetDetailId(productId); PropModified <ProductDetail> modified = new PropModified <ProductDetail>(new { isDel = true }); using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context)) return(db.Update(detailId, modified)); }
public bool UpdateStatusDTO(string productId, bool status) { if (DataHelper.IsEmptyString(productId)) { return(false); } var detailId = DataHelper.GetDetailId(productId); PropModified <ProductDetail> modified = new PropModified <ProductDetail>(new { isShow = status }); using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context)) return(db.Update(detailId, modified)); }
public bool UpdateStatus(int id, byte status) { PropModified <Order> modified = new PropModified <Order>(new { Status = (status) }); using (var db = new OrderDAO(_context)){ if (status == 0) { db.RestoreQuantity(id); } return(db.Update(id, modified)); } }
public bool UpdateDTO(string productId, ProductDetailDTO productDetailDTO) { if (DataHelper.IsEmptyString(productId)) { return(false); } var detailId = DataHelper.GetDetailId(productId); var prod = ObjectMapperTo <ProductDetailDTO, ProductDetail>(productDetailDTO); PropModified <ProductDetail> modified = new PropModified <ProductDetail>(prod); using (EntityDAO <ProductDetail> db = new EntityDAO <ProductDetail>(_context)) return(db.Update(detailId, modified)); }
public virtual bool Update(object id, PropModified <T> modified) { if (!CheckConnection() || id == null) { return(false); } T obj = _context.Find <T>(id); if (obj == null) { return(false); } modified.UpdateFor(ref obj); _context.SaveChangesAsync().Wait(); return(true); }
public bool UpdateDTO(int idSrc, T objVM, string[] ignore = null) { if (idSrc < 0 || objVM == null) { return(false); } V obj = ObjectMapperTo <T, V>(objVM); PropModified <V> modifieds = new PropModified <V>(obj, ignore); if (!modifieds.isChanged) { return(false); } // using (EntityDAO <V> db = new EntityDAO <V>(_context)) return(db.Update(idSrc, modifieds)); }
public IActionResult Update(string id, PostDTO postDTO) { if (DataHelper.IsEmptyString(id)) { return(BadRequest(new { message = "ID is invalid" })); } var itemId = DataHelper.GetDetailId(id); var modified = new PropModified <PostDTO> (postDTO); if (!modified.isChanged) { return(BadRequest()); } if (!_postModel.UpdateDTO(itemId, postDTO)) { return(Problem(statusCode: 500, detail: "Can't update data")); } return(Ok()); }
public ActionResult <String> AddProductDetail(int cateId, ProductDetailDTO productDetailDTO) { if (!ModelState.IsValid) { return(BadRequest()); } // var modified = new PropModified <ProductDetailDTO>(productDetailDTO); if (!modified.isChanged || cateId <= 0) { return(BadRequest()); } var re = _productModel.AddDTOs(cateId, productDetailDTO); if (re == null) { return(Problem(statusCode: 500, detail: "Can't add data")); } _cache.DataUpdated(CacheKey.PRODUCT); return(Ok(re.Id)); }