Exemple #1
0
        public string Update <Buy_Order>(int id, Library.Models.Buy_Order order)
        {
            try
            {
                Library.Models.Buy_Order newOrder = context.BuyOrders.Find(id);

                if (newOrder == null)
                {
                    return("Такого заказа нет");
                }
                using (var dbCtx = new LibraryContext())
                {
                    newOrder.Id_employee        = order.Id_employee;
                    newOrder.Id_book            = order.Id_book;
                    dbCtx.Entry(newOrder).State = System.Data.Entity.EntityState.Modified;
                    dbCtx.SaveChanges();
                }

                context = new LibraryContext();
                return("Данные изменены");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
 public string Insert <Buy_Order>(Library.Models.Buy_Order order)
 {
     try
     {
         context.BuyOrders.Add(order);
         context.SaveChanges();
         return("Запись была добавлена");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 public string Delete <Buy_Order>(Library.Models.Buy_Order order)
 {
     try
     {
         var delBook = context.BuyOrders.Find(order.Id);
         context.BuyOrders.Remove(delBook);
         context.SaveChanges();
         return("Запись удалена");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
        static public string FromBuyOrder(int Id_employee, int Id_book)
        {
            try
            {
                DBManager manager  = new DBManager();
                var       buyOrder = new Buy_Order();
                buyOrder.Id_employee = Id_employee;
                buyOrder.Id_book     = Id_book;

                return(manager.Insert <Buy_Order>(buyOrder));
            }
            catch (Exception ex)
            {
                return("Не удалось добавить новую запись. Ошибка: " + ex.Message);
            }
        }