Esempio n. 1
0
        public string Update <Reading_Order>(int id, Library.Models.Reading_Order order)
        {
            try
            {
                Library.Models.Reading_Order newOrder = context.ReadingOrders.Where(s => s.Id == id).FirstOrDefault();

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

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

                readingOrder.Id_employee = Id_employee;
                readingOrder.Id_book     = Id_book;

                return(manager.Insert <Reading_Order>(readingOrder));
            }
            catch (Exception ex)
            {
                return("Не удалось добавить новую запись. Ошибка: " + ex.Message);
            }
        }
Esempio n. 5
0
        static public string FromReadingOrder(int Id)
        {
            try
            {
                DBManager manager      = new DBManager();
                var       readingOrder = new Reading_Order();

                Reading_Order order = new Reading_Order {
                    Id = Id
                };

                return(manager.Delete <Reading_Order>(order));
            }
            catch (Exception ex)
            {
                return("Не удалось удалить запись. Ошибка: " + ex.Message);
            }
        }