//shortly code insert to db public bool CreateNewProduct(ProductViewContract product) { try { db.Information.Add(new Information { titleInfo = product.Title, contentInfo = product.Content, idCate = product.CateId, idUser = product.UserId, dayCreateInfo = product.DateCreate, hideInfo = product.hideInfo, }); if (db.SaveChanges() > 0) { return(true); } else { return(false); } } catch (Exception e) { Console.WriteLine(e); return(false); } }
public ProductViewContract getContentById(int id) { var data = new ProductDao().GetDetailProductById(id); var res = new ProductViewContract() { ID = data.idInfor, Title = data.titleInfo, User = new UserContract() { ID = data.User.idUser, UserName = data.User.nameUser, ProductViewContracts = data.User.Information.Where(x => x.idInfor != data.idInfor && x.idUser == data.idUser).Select(x => new ProductViewContract { ID = x.idInfor, Title = x.titleInfo, EditInforCount = x.EditInfoes.Count, DateCreate = x.dayCreateInfo }).ToList() }, Category = new CategoryContract() { ID = data.Category.idCate, Name = data.Category.nameCate }, EditInforCount = data.EditInfoes.Count, EditProductViewContracts = data.EditInfoes.Select(x => new EditProductViewContract() { ID = x.idEI, User = new UserContract() { ID = x.idUser, UserName = x.User.nameUser }, DateCreateEI = x.dayCreateEI, Content = x.contentEdit, ProductId = x.idInfo, UserID = x.idUser }).ToList(), Content = data.contentInfo, DateCreate = data.dayCreateInfo, }; return(res); }
public bool EditProduct(ProductViewContract product) { try { var data = db.Information.Find(product.ID); data.titleInfo = product.Title; data.contentInfo = product.Content; data.idCate = product.CateId; if (db.SaveChanges() > 0) { return(true); } else { return(false); } } catch (Exception e) { Console.WriteLine(e); return(false); } }
public ProductViewContract GetDetailProductById(int id) { var result = new ProductDao().GetDetailProductById(id); var data = new ProductViewContract() { ID = result.idInfor, Title = result.titleInfo, CateId = result.idCate, UserId = result.idUser, User = new UserContract() { ID = result.idUser, UserName = result.User.nameUser }, UserName = result.User.nameUser, CategoryName = result.Category.nameCate, DateCreate = result.dayCreateInfo, Content = result.contentInfo, hideInfo = result.hideInfo, EditInforCount = result.EditInfoes.Count() }; return(data); }
public bool EditProduct(ProductViewContract product) { return(new ProductDao().EditProduct(product)); }
public bool CreateProduct(ProductViewContract product) { product.DateCreate = DateTime.Now; product.hideInfo = true; return(new ProductDao().CreateNewProduct(product)); }
public bool CreateNewProduct(ProductViewContract product) { return(new ProductBus().CreateProduct(product)); }
public bool UpdateProduct(ProductViewContract product) { throw new NotImplementedException(); }
public bool EditProduct(ProductViewContract product) { return(new Responsetory().EditProduct(product)); }
public bool CreateNewProduct(ProductViewContract product) { return(new Responsetory().CreateNewProduct(product)); }