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)); } }
public static EventsDto PostEvent(EventsDto events) { using (familydbEntities9 db = new familydbEntities9()) { db.Events.Add(Convertion.EventsConvertion.ConvertToEventNoChildren(events)); db.SaveChanges(); return(events); } }
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)); } }
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); } }
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(); } }
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)); } }
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)); } }
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); } }