예제 #1
0
        public static EventsDto UpdateEvents(EventsDto events)
        {
            using (familydbEntities9 db = new familydbEntities9())
            {
                var events1 = db.Events.FirstOrDefault(e => e.Id == events.Id);
                if (events1 != null)
                {
                    Events e = Convertion.EventsConvertion.ConvertToEventNoChildren(events);
                    events1.Address     = e.Address;
                    events1.City        = e.City;
                    events1.Comment     = e.Comment;
                    events1.Date        = e.Date;
                    events1.Description = e.Description;
                    events1.EventKindId = e.EventKindId;
                    events1.EventsKind  = e.EventsKind;
                    events1.GroupId     = e.GroupId;
                    events1.Id          = e.Id;
                    events1.IsDairy     = e.IsDairy;
                    events1.Promoter    = e.Promoter;
                    events1.Repeat      = e.Repeat;
                    events1.Title       = e.Title;
                }
                db.SaveChanges();

                return(Convertion.EventsConvertion.ConvertToDto(events1));
            }
        }
예제 #2
0
 public static EventsDto PostEvent(EventsDto events)
 {
     using (familydbEntities9 db = new familydbEntities9())
     {
         db.Events.Add(Convertion.EventsConvertion.ConvertToEventNoChildren(events));
         db.SaveChanges();
         return(events);
     }
 }
예제 #3
0
 public static EventsDto CreateEvents(EventsDto events)
 {
     using (familydbEntities9 db = new familydbEntities9())
     {
         Events events1 = Convertion.EventsConvertion.ConvertToEventNoChildren(events);
         db.Events.Add(events1);
         db.SaveChanges();
         return(Convertion.EventsConvertion.ConvertToDto(events1));
     }
 }
예제 #4
0
 public static MenuDto DeleteMenu(int menuId)
 {
     using (familydbEntities9 db = new familydbEntities9())
     {
         Menu    m  = db.Menu.Where(x => x.Id == menuId).FirstOrDefault();
         MenuDto m1 = Convertion.MenuConvertion.ConvertToDto(m);
         db.Menu.Remove(m);
         db.SaveChanges();
         return(m1);
     }
 }
예제 #5
0
 public static void SaveImage(int id, string fileName, string name)
 {
     using (familydbEntities9 db = new familydbEntities9())
     {
         Events find = new Events();
         var    pic  = new Picture()
         {
             EventId = id, Image = fileName, Name = name
         };
         db.Picture.Add(pic);
         db.SaveChanges();
     }
 }
예제 #6
0
 public static MenuDto CreateMenu(MenuDto menu)
 {
     using (familydbEntities9 db = new familydbEntities9())
     {
         Menu m = new Menu();
         m = db.Menu.Add(Convertion.MenuConvertion.ConvertToMenuWithoutIncluse(menu));
         db.SaveChanges();
         if (m == null)
         {
             return(null);
         }
         return(Convertion.MenuConvertion.ConvertToDto(m));
     }
 }
예제 #7
0
        public static MenuDto UpdateMenu(MenuDto menu)
        {
            using (familydbEntities9 db = new familydbEntities9())
            {
                var menu1 = db.Menu.FirstOrDefault(m => m.Id == menu.Id);
                if (menu1 != null)
                {
                    Menu m = Convertion.MenuConvertion.ConvertToMenuWithoutIncluse(menu);
                    menu1.Cost            = m.Cost;
                    menu1.EventId         = m.EventId;
                    menu1.Id              = m.Id;
                    menu1.MenuOrderNumber = m.MenuOrderNumber;
                    menu1.Name            = m.Name;
                    menu1.Quantity        = m.Quantity;
                    menu1.VolunteerId     = m.VolunteerId;
                    menu1.User            = m.User;
                }
                db.SaveChanges();

                return(Convertion.MenuConvertion.ConvertToDto(menu1));
            }
        }
예제 #8
0
 public static EventsDto DeleteEvent(int events)
 {
     using (familydbEntities9 db = new familydbEntities9())
     {
         List <Menu> find = new List <Menu>();
         find = db.Menu.Where(x => x.EventId == events).ToList();
         foreach (var item in find)
         {
             db.Menu.Remove(item);
         }
         List <Picture> find1 = new List <Picture>();
         find1 = db.Picture.Where(x => x.EventId == events).ToList();
         foreach (var item in find1)
         {
             db.Picture.Remove(item);
         }
         Events    e  = db.Events.Where(x => x.Id == events).FirstOrDefault();
         EventsDto e1 = Convertion.EventsConvertion.ConvertToDto(e);
         db.Events.Remove(e);
         db.SaveChanges();
         return(e1);
     }
 }