Exemple #1
0
 /// <summary>
 /// Get all stores
 /// </summary>
 public static List <StoreDTO> GetStores()
 {
     try
     {
         using (SuperZapatosContext db = new SuperZapatosContext())
         {
             return((from s in db.Stores
                     select new StoreDTO()
             {
                 id = s.id,
                 name = s.name,
                 address = s.address
             }).ToList());
         };
     }
     catch (Exception ex)
     {
         string sMsg = string.Format("SuperZapatos.GetStores");
         throw new Exception(sMsg, ex);
     }
 }
Exemple #2
0
 /// <summary>
 /// Get stores by id
 /// </summary>
 public static StoreDTO GetStoreById(int id)
 {
     try
     {
         using (SuperZapatosContext db = new SuperZapatosContext())
         {
             return((from s in db.Stores
                     where s.id == id
                     select new StoreDTO()
             {
                 id = s.id,
                 name = s.name,
                 address = s.address
             }).FirstOrDefault());
         };
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 /// <summary>
 ///  Update Article
 /// </summary>
 public static void UpdateArticle(ArticleDTO articleDTO)
 {
     try
     {
         using (SuperZapatosContext db = new SuperZapatosContext())
         {
             var articleDB = new Article();
             articleDB.name            = articleDTO.name;
             articleDB.description     = articleDTO.description;
             articleDB.price           = articleDTO.price;
             articleDB.total_in_shelf  = articleDTO.total_in_shelf;
             articleDB.total_in_vault  = articleDTO.total_in_vault;
             articleDB.store_id        = articleDTO.store_id;
             db.Entry(articleDB).State = EntityState.Modified;
             db.SaveChanges();
         };
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }