/// <summary> /// in this function we take all the orders that connected in to this hosting unit /// and check if there any open order to this hosting unit /// </summary> /// <param name="hostingUnit"></param> /// <returns></returns> public bool DeleteableHostingUnit(BO.HostingUnit hostingUnit)// { var orders = from item in dal.GetOrdersList(x => x.HostingUnitKey == hostingUnit.Key) where IsOpenOrder(Conversions.CastingToBO_Order(item)) select item; return(!orders.Any());//check if there is somthing in the orders }
public void DeleteHostingUnit(BO.HostingUnit hostingUnit)// { if (DeleteableHostingUnit(hostingUnit)) { dal.DeleteHostingUnit(Conversions.CastingToDOHostingUnit(hostingUnit)); } else { throw new InvalidOperationException("It is impossible to delete a hosting unit that has open orders"); } }
public static DO.HostingUnit Conv_BO_To_DO(BO.HostingUnit item) { DO.HostingUnit temp = new DO.HostingUnit(); temp.Key = item.Key; temp.HostingUnitName = item.HostingUnitName; temp.NumOfOffers = item.NumOfOffers; temp.HostId = item.HostId; temp.pricePerNight = item.PricePerNight; temp.Status = (DO.ActivityStatus)item.Status; temp.Diary = item.Diary;///////////////////////////////////////////////////////////////////////////////////////////// return(temp); }
public void UpdateStatusOrder(BO.OrderStatus updateorder, int key) { try { BO.Order tmp1 = Converters.Conv_DO_To_BO(dal.GetOrder(key)); if (tmp1.Status == OrderStatus.IGNORED_CLOSED || tmp1.Status == OrderStatus.APPROVED) { throw new Exception("אין אפשרות לשנות את הסטטוס לאחר סגירת עסקה"); } BO.Host temp2 = Converters.Conv_DO_To_BO(dal.GetHost(tmp1.HostId)); if (updateorder == OrderStatus.MAIL_SENT) { if (!temp2.CollectionClearance) { throw new Exception("אין אפשרות לשלוח מייל ללקוח מבלי לחתום על הרשאה לחיוב חשבון"); } } if (updateorder == OrderStatus.APPROVED) { BO.Order update = Converters.Conv_DO_To_BO(dal.GetOrder(key)); BO.HostingUnit unit = Converters.Conv_DO_To_BO(dal.GetHostingUnit(update.HostingUnitKey)); BO.GuestRequest request = Converters.Conv_DO_To_BO(dal.GetGuestRequest(update.GuestRequestKey)); SetDairy(unit, request); dal.UpdateHostingUnit(Converters.Conv_BO_To_DO(unit)); update.ClientName = dal.GetPerson(update.ClientId).FirstName + dal.GetPerson(update.ClientId).LastName; update.Commission = 10; //סכום העמלה dal.UpdateOrder(Converters.Conv_BO_To_DO(update)); List <Order> lst = GetOrdersByRequestKey(request.Key).ToList(); foreach (var i in lst)//change all orders to Irrelevant { if (i.Key != update.Key) { dal.UpdateStatusOrder(i.Key, DO.OrderStatus.IRRELEVANT); } } try { SendEmail(tmp1); } catch (Exception) { throw new Exception("Check your Internet connection"); } //////////////////////////////////////////////////////////////////////////////////////// } dal.UpdateStatusOrder(key, (DO.OrderStatus)updateorder); } catch (Exception e) { throw e; } }
public bool IsAvailableGuestRequest(BO.GuestRequest guestRequest, BO.HostingUnit hostingUnit)// { DateTime temp = guestRequest.EntryDate; while (temp != guestRequest.ReleaseDate) { if (hostingUnit.GetDate(temp) == true) { return(false); } temp = temp.AddDays(1); } return(true); }
public static DO.HostingUnit Conv_BO_To_DO(BO.HostingUnit item) { DO.HostingUnit temp = new DO.HostingUnit(); temp.Key = item.Key; temp.HostingUnitName = item.HostingUnitName; temp.NumOfOffers = item.NumOfOffers; temp.HostId = item.HostId; temp.pricePerNight = item.PricePerNight; temp.Status = (DO.ActivityStatus)item.Status; temp.Diary = item.Diary; temp.Area = (DO.Areas)item.Area; temp.Garden = item.Garden; temp.Jacuzzi = item.Jacuzzi; temp.Pool = item.Pool; temp.Rooms = item.Rooms; temp.Type = (DO.HostingType)item.Type; return(temp); }
public static BO.HostingUnit CastingToBOHostingUnit(DO.HostingUnit hostingUnit) { BO.HostingUnit HU = new BO.HostingUnit() { Diary = hostingUnit.Diary, HostingUnitName = hostingUnit.HostingUnitName, Key = hostingUnit.Key, Owner = hostingUnit.Owner, Status = (BO.Status)hostingUnit.Status, Area = (BO.Location)hostingUnit.Area, ImageLink1 = hostingUnit.ImageLink1, ImageLink2 = hostingUnit.ImageLink2, ImageLink3 = hostingUnit.ImageLink3, Jacuzzi = hostingUnit.Jacuzzi, Kitchen = hostingUnit.Kitchen, SwimmingPool = hostingUnit.SwimmingPool, TV = hostingUnit.TV, WIFI = hostingUnit.WIFI, PricePerNight = hostingUnit.PricePerNight }; return(HU); }
public int NumberOfSentOrders(BO.HostingUnit hostingUnit)// { return(dal.GetOrdersList(x => x.HostingUnitKey == hostingUnit.Key).Count()); }
public int AddHostingUnit(BO.HostingUnit hostingUnit)// { return(dal.AddHostingUnit(Conversions.CastingToDOHostingUnit(hostingUnit))); }
public void UpdateHostingUnit(BO.HostingUnit hostingUnit) { dal.UpdateHostingUnit(Conversions.CastingToDOHostingUnit(hostingUnit)); }
static public void SetDate(this BO.HostingUnit hostingUnit, DateTime dateTime, bool value) { hostingUnit.Diary[dateTime.Month - 1, dateTime.Day - 1] = value; }
static public bool GetDate(this BO.HostingUnit hostingUnit, DateTime dateTime) { return(hostingUnit.Diary[dateTime.Month - 1, dateTime.Day - 1]); }