/// <summary> /// delete Hosting Unit to date base /// </summary> /// <param name="hostingunit"></param> public void DeleteHostingUnit(BE.HostingUnit hostingunit) { BE.HostingUnit tmp = null; tmp = DS.DataSource.HostingUnits.Single(x => x.Hostingunitkey == hostingunit.Hostingunitkey); //lambda if (tmp == null) { throw new SomeException("לא קיימת יחידת דיור כזאת"); } //bool tmp = false; foreach (var item in IDAL.GetOrderList()) { if (item.HostingunitKey == hostingunit.Hostingunitkey && item.Status != BE.StatusGuest.נסגר_בהענות_של_הלקוח && item.Status != BE.StatusGuest.נסגר_מחוסר_הענות_של_הלקוח) { throw new SomeException(" לא ניתן למחוק יחידת אירוח כל עוד יש הצעה הקשורה אליה במצב פתוח"); } } IDAL.DeleteHostingUnit(hostingunit); }
public void DeleteHostingUnit(HostingUnit myHostingUnit) { try { var openOrdersByUnit = from order in dal.ReceiveOrderList() let unitKey = myHostingUnit.HostingUnitKey where order.HostingUnitKey == unitKey && order.Status != Enum_s.OrderStatus.נסגר_בשל_התנגשות && order.Status != Enum_s.OrderStatus.נסגר_בשל_חוסר_הענות && order.Status != Enum_s.OrderStatus.נסגר_בשל_פגות_תוקף && order.Status != Enum_s.OrderStatus.נסגר_בשל_רכישה_אחרת select order; if (openOrdersByUnit.Count() != 0) { throw new DeleteUnitWithOpenOrdersException("מצטערים, אינך יכול למחוק יחידת אירוח זו. קיימות הזמנות פתוחות עבור היחידה"); } dal.DeleteHostingUnit(myHostingUnit); } catch (Exception ex) { throw ex; } }