Пример #1
0
 /// <summary>
 /// Create Store
 /// </summary>
 public static void CreateStore(StoreDTO storeDTO)
 {
     try
     {
         using (SuperZapatosContext db = new SuperZapatosContext())
         {
             var storeDB = new Store();
             storeDB.name    = storeDTO.name;
             storeDB.address = storeDTO.address;
             db.Stores.Add(storeDB);
             db.SaveChanges();
         };
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        /// <summary>
        /// Remove  store
        /// </summary>
        public static StoreDTO DeleteStore(int id)
        {
            try
            {
                using (SuperZapatosContext db = new SuperZapatosContext())
                {
                    var storeToDelete = GetStoreById(id);

                    var storemodel = db.Stores.Find(id);
                    db.Stores.Remove(storemodel);
                    db.SaveChanges();
                    return(storeToDelete);
                };
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
 /// <summary>
 ///  Update store
 /// </summary>
 public static void UpdateStore(StoreDTO storeDTO)
 {
     try
     {
         using (SuperZapatosContext db = new SuperZapatosContext())
         {
             var storeDB = new Store();
             storeDB.name            = storeDTO.name;
             storeDB.address         = storeDTO.address;
             storeDB.id              = storeDTO.id;
             db.Entry(storeDB).State = EntityState.Modified;
             db.SaveChanges();
         };
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #4
0
        /// <summary>
        /// Remove article
        /// </summary>
        public static ArticleDTO DeleteArticle(int id)
        {
            try
            {
                using (SuperZapatosContext db = new SuperZapatosContext())
                {
                    var articleToDelete = GetArticleById(id);
                    var articlemodel    = db.Articles.Find(id);
                    db.Articles.Remove(articlemodel);
                    db.SaveChanges();

                    return(articleToDelete);
                };
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
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;
     }
 }