public void RemoveListFromGroup(string groupPublicID, string listPublicID, string userName) { EveShoppingContext contexto = new EveShoppingContext(); eshGroupShoppingList sl; eshSnapshot snap; CommonTestGetForGroupShoppingListUpdate(groupPublicID, listPublicID, userName, contexto, out sl); LogicaSnapshots logicaSnap = new LogicaSnapshots(); snap = logicaSnap.SelectStaticListByPublicID(listPublicID); if (snap == null) { throw new ApplicationException(Messages.err_staticShoppingListNoExiste); } eshGroupShoppingListSnapshot gsls = contexto.eshGroupShoppingListSnapshots.Where(gs => gs.snapshotID == snap.snapshotID && gs.groupShoppingListID == sl.groupShoppingListID).FirstOrDefault(); if (gsls == null) { throw new ApplicationException(); } contexto.eshGroupShoppingListSnapshots.Remove(gsls); contexto.SaveChanges(); }
public string AddListToGroup(string groupPublicID, string listPublicID, string userName, string nick, IImageResolver resolver = null) { EveShoppingContext contexto = new EveShoppingContext(); string snapPublicID = null; eshGroupShoppingList sl; eshSnapshot snap; CommonTestGetForGroupShoppingListUpdate(groupPublicID, listPublicID, userName, contexto, out sl); LogicaSnapshots logicaSnap = new LogicaSnapshots(); snap = logicaSnap.SelectStaticListByPublicID(listPublicID); //if not snapshot, we check if it is a normal list if (snap == null) { snap = logicaSnap.CreateStaticShoppingList(listPublicID, null, resolver); } // if not snapshot, we check if it is a group list //if (snap == null) //{ // snap = logicaSnap.CreateStaticShoppingListFromGroup(listPublicID, null, resolver); //} if (snap == null) { throw new ApplicationException(Messages.err_staticShoppingListNoExiste); } eshGroupShoppingListSnapshot rel = new eshGroupShoppingListSnapshot(); rel.groupShoppingListID = sl.groupShoppingListID; rel.nickName = nick; rel.snapshotID = snap.snapshotID; rel.creationDate = System.DateTime.Now; sl.dateUpdate = System.DateTime.Now; contexto.eshGroupShoppingListSnapshots.Add(rel); contexto.SaveChanges(); return(snap.publicID); }