public List <UserBE> GetUserAll() { List <UserBE> ltsuser = new List <UserBE>(); MasterProductContext BDMP = new MasterProductContext(); try { ltsuser = (from User in BDMP.User select new UserBE { IdUser = User.IdUser, NameUser = User.NameUser, Photo = User.Photo }).OrderBy(x => x.NameUser).ToList(); } catch (Exception EX) { } finally { BDMP.Dispose(); } return(ltsuser); }
public List <ProductBE> GetProductdTAll(bool STATPROD) { List <ProductBE> lstprod = new List <ProductBE>(); MasterProductContext BDMP = new MasterProductContext(); try { lstprod = (from Product in BDMP.Product where Product.StateProduct == STATPROD select new ProductBE { IdProduct = Product.IdProduct, NameProduct = Product.NameProduct, Properties = Product.Properties, ReleaseDate = Product.ReleaseDate, ManufacturerEmail = Product.ManufacturerEmail, IdCountry = Product.IdCountry, Cost = Product.Cost, UnitsAvailable = Product.UnitsAvailable, SoldUnits = Product.SoldUnits, StateProduct = Product.StateProduct, ImageProduct = Product.ImageProduct }).OrderBy(x => x.ReleaseDate).ThenBy(x => x.StateProduct).ToList(); } catch (Exception EX) { } finally { BDMP.Dispose(); } return(lstprod); }
public ProductBE SearchIdProduct(int SEARIDPROCUP) { MasterProductContext BDMP = new MasterProductContext(); ProductBE idprocupbo = new ProductBE(); try { idprocupbo = (from Product in BDMP.Product where Product.IdProduct == SEARIDPROCUP select new ProductBE { IdProduct = Product.IdProduct, NameProduct = Product.NameProduct, Properties = Product.Properties, ReleaseDate = Product.ReleaseDate, ManufacturerEmail = Product.ManufacturerEmail, IdCountry = Product.IdCountry, Cost = Product.Cost, UnitsAvailable = Product.UnitsAvailable, SoldUnits = Product.SoldUnits, StateProduct = Product.StateProduct, ImageProduct = Product.ImageProduct }).FirstOrDefault(); } catch (Exception EX) { } finally { BDMP.Dispose(); } return(idprocupbo); }
public AnswerResponseBE InsertProduct(ProductBE IPROD) { AnswerResponseBE AR = new AnswerResponseBE(); MasterProductContext BDMP = new MasterProductContext(); try { int CountProd = 0; CountProd = BDMP.Product.Where(x => x.IdProduct == IPROD.IdProduct).ToList().Count(); if (CountProd == 0) { Product PROD = new Product(); PROD.IdProduct = IPROD.IdProduct; PROD.NameProduct = IPROD.NameProduct; PROD.Properties = IPROD.Properties; PROD.ReleaseDate = IPROD.ReleaseDate; PROD.ManufacturerEmail = IPROD.ManufacturerEmail; PROD.IdCountry = IPROD.IdCountry; PROD.Cost = IPROD.Cost; PROD.UnitsAvailable = IPROD.UnitsAvailable; PROD.SoldUnits = IPROD.SoldUnits; PROD.StateProduct = IPROD.StateProduct; PROD.ImageProduct = IPROD.ImageProduct; BDMP.Product.Add(PROD); BDMP.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha insertado el producto correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El producto ya existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDMP.Dispose(); } return(AR); }
public AnswerResponseBE UpdateProduct(ProductBE UPROD) { AnswerResponseBE AR = new AnswerResponseBE(); MasterProductContext BDMP = new MasterProductContext(); try { Product product = new Product(); product = BDMP.Product.Where(x => x.IdProduct == UPROD.IdProduct).FirstOrDefault(); if (product != null) { product.IdProduct = UPROD.IdProduct; product.NameProduct = UPROD.NameProduct; product.Properties = UPROD.Properties; product.ReleaseDate = UPROD.ReleaseDate; product.ManufacturerEmail = UPROD.ManufacturerEmail; product.IdCountry = UPROD.IdCountry; product.Cost = UPROD.Cost; product.UnitsAvailable = UPROD.UnitsAvailable; product.SoldUnits = UPROD.SoldUnits; product.StateProduct = UPROD.StateProduct; product.ImageProduct = UPROD.ImageProduct; BDMP.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha actualizado el producto correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro no existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDMP.Dispose(); } return(AR); }
public AnswerResponseBE UpdateUser(UserBE UPUS) { AnswerResponseBE AR = new AnswerResponseBE(); MasterProductContext BDMP = new MasterProductContext(); try { User user = new User(); user = BDMP.User.Where(x => x.IdUser == UPUS.IdUser).FirstOrDefault(); if (user != null) { user.IdUser = UPUS.IdUser; user.NameUser = UPUS.NameUser; user.Photo = UPUS.Photo; BDMP.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha actualizado el usuario correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El registro no existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDMP.Dispose(); } return(AR); }
public AnswerResponseBE InsertUser(UserBE IUS) { AnswerResponseBE AR = new AnswerResponseBE(); MasterProductContext BDMP = new MasterProductContext(); try { int CountUser = 0; CountUser = BDMP.User.Where(x => x.IdUser == IUS.IdUser).ToList().Count(); if (CountUser == 0) { User USER = new User(); USER.IdUser = IUS.IdUser; USER.NameUser = IUS.NameUser; USER.Photo = IUS.Photo; BDMP.User.Add(USER); BDMP.SaveChanges(); AR.CodeError = 0; AR.DescriptionError = "Se ha insertado el usuario correctamente"; } else { AR.CodeError = 2; AR.DescriptionError = "El usuario ya existe, por favor verifique la información"; } } catch (Exception EX) { AR.CodeError = 1; AR.DescriptionError = "Hubo un error"; } finally { BDMP.Dispose(); } return(AR); }