public void updateHostingUnit(BE.HostingUnit hostUnit) { if (hostUnit.HostingUnitKey == 0) //זה אומר שאין קוד ייחודי שהרי הערך לא מאותחל על ברירת מחדל { hostUnit.HostingUnitKey = BE.Configuration.geustReqID++; //הענק לו קוד ייחודי } ds.getHostingUnitList().RemoveAll(x => x.HostingUnitKey == hostUnit.HostingUnitKey); addHostingUnit(hostUnit.Clone()); //עדכון כללי כאן. //var obj = ds.getHostingUnitList().FirstOrDefault(x => x.HostingUnitKey == hostUnit.HostingUnitKey); //if (obj != null) obj = hostUnit; //else if (obj == null) //אם איו מופע כנ"ל משמע שלא מצא אותו ברשימה //{ // throw new KeyNotFoundException(string.Format("Hosting Unit {0} not exsits in getHostingUnitList data ", hostUnit)); //} ////מחיקת קודם ונעדכן חדש... //var itemToRemove = ds.getHostingUnitList().SingleOrDefault(r => r.HostingUnitKey == hostUnit.HostingUnitKey); //if (itemToRemove != null) //{ // ds.getHostingUnitList().Remove(itemToRemove); //מחיקת הערך // ds.getHostingUnitList().Add(hostUnit.Clone()); // עדכון חדש //} }
public void updateHostingUnit(BE.HostingUnit hostUnit) { if (hostUnit.HostingUnitKey == 0) //זה אומר שאין קוד ייחודי שהרי הערך לא מאותחל על ברירת מחדל { hostUnit.HostingUnitKey = BE.Configuration.GetHostingUnitKey(); //הענק לו קוד ייחודי } HostingUnitList1.RemoveAll(x => x.HostingUnitKey == hostUnit.HostingUnitKey); addHostingUnit(hostUnit.Clone()); //BE.Tools.SaveToXML<List<HostingUnit>>(HostingUnitList1, BE.Tools.HostingUnitPath); }
public void DeleteHostingUnit(BE.HostingUnit hostingUnit) { if (IsPossibleToDelete(hostingUnit)) { _dal.DeleteHostingUnit(hostingUnit.Clone()); } else { throw new ArgumentException($"cannot delete hostingunit({hostingUnit.HostingUnitKey}/({hostingUnit.HostingUnitName})" + $"needed to first close all the orders)"); } }
/// <summary> /// updates a hosting unit's size /// </summary> /// <param name="unit"></param> /// <param name="size"></param> public void UpdateHostingUnitSize(BE.HostingUnit unit, int size) { try { unit.Size = size; UpdateHostingUnit(unit.Clone()); } catch (Exception e) { throw e; } }
//HostingUnit public void addHostingUnit(BE.HostingUnit hostUnit) { hostUnit.HostingUnitKey = BE.Configuration.hostUnitID++;// לוודא שאכן מקדם אותו foreach (BE.HostingUnit element in GetHostingUnitList()) { if (element.isEqual(hostUnit)) { throw new DuplicateWaitObjectException(/* "ישנו מספר זהה של יחידת אירוח"*/ "Cannot add.duplicate HostingUnit key on data "); } } ds.getHostingUnitList().Add(hostUnit.Clone()); }
public void updateHostingUnit(BE.HostingUnit hostUnit) { BE.HostingUnit beforeChangeHostUnit = getHostingUnitByID(hostUnit.HostingUnitKey); //אם לא הושלם מילוי if (/*hostUnit.Owner == null ||*/ hostUnit.HostingUnitName == "" || hostUnit.Owner.PrivateName == "" || hostUnit.Owner.FamilyName == "" || hostUnit.Owner.PhoneNumber == "" || hostUnit.Owner.MailAddress == null || hostUnit.Owner.BankBranchDetails == null || hostUnit.Owner.BankAccountNumber == 0) { throw new ArgumentException("חובה למלא את כל השדות"); } if (!BE.Tools.ValidateID(hostUnit.Owner.HostKey)) { throw new System.IO.InvalidDataException("תעודת זהות של מארח לא תקינה."); } if (!Enum.IsDefined(typeof(BE.AreaEnum), hostUnit.Area)) { throw new System.IO.InvalidDataException("Enum input illegal"); } if (hostUnit.Area == BE.AreaEnum.All) { throw new System.IO.InvalidDataException("Enum input illegal. HostingUnit cannot be in All regions"); } if (beforeChangeHostUnit.Owner.CollectionClearance.Equals("Yes") && (hostUnit.Owner.CollectionClearance.Equals("No")))//אם רוצה לשנות הרשאת חשבון בנק { var checkOrder = from item in GetOrderList() where (item.HostingUnitKey == hostUnit.HostingUnitKey) && ((item.Status == BE.StatusEnum.טרם_טופל) || (item.Status == BE.StatusEnum.נשלח_מייל)) select item; foreach (var item in checkOrder) { throw new System.ArgumentException("לא ניתן לבטל הראשאת חיוב חשבון כל עוד יש הזמנה פתוחה"); } } // after we cheek all the possible problems we can transfer the data to DAL layer try { IDAL.updateHostingUnit(hostUnit.Clone()); } catch (KeyNotFoundException e) { throw e; } }
//public void addGuestRequest(BE.GuestRequest guest) //{ // bool exists = GuestRequestList1.Any(x => x.GuestRequestKey == guest.GuestRequestKey); // if (exists) // { // throw new DuplicateWaitObjectException((/* "ישנו מספר זהה של דרישת אירוח"*/"Cannot add.duplicate GuestRequest key on data ")); // } // if (guest.GuestRequestKey == 0) // { // guest.GuestRequestKey = BE.Configuration.GetGuestRequestKey(); // } // GuestRequestList1.Add(guest.Clone()); // BE.Tools.SaveToXML<List<BE.GuestRequest>>(GuestRequestList1, BE.Tools.GuestPath); //} //public void updateGuestRequest(BE.GuestRequest guest) //{ // if (guest.GuestRequestKey == 0)//זה אומר שאין קוד ייחודי שהרי הערך לא מאותחל על ברירת מחדל- דרישות דף פרוייקט. // guest.GuestRequestKey = BE.Configuration.GetGuestRequestKey(); //הענק לו קוד ייחודי // //אם זה קיים הוא מוחק ישן ושם חדש. אם לא קיים, פשוט יוסיף אותו. // GuestRequestList1.RemoveAll(x => x.GuestRequestKey == guest.GuestRequestKey); // addGuestRequest(guest); // //אם איו מופע כנ"ל משמע שלא מצא אותו ברשימה //} //public BE.GuestRequest getGuestRequestByID(int ID) //{ // var list = from item in GetGuestRequestList() // where item.GuestRequestKey == ID // select item.Clone(); // return list.FirstOrDefault(); //} #endregion #endregion #region HostingUnit //HostingUnit public int addHostingUnit(BE.HostingUnit hostUnit) { if (hostUnit.HostingUnitKey == 0) { hostUnit.HostingUnitKey = BE.Configuration.GetHostingUnitKey(); } if (HostingUnitList1.Any(x => x.HostingUnitKey == hostUnit.HostingUnitKey)) { throw new DuplicateWaitObjectException(/* "ישנו מספר זהה של יחידת אירוח"*/ "Cannot add.duplicate HostingUnit key on data "); } HostingUnitList1.Add(hostUnit.Clone()); BE.Tools.SaveToXML <List <BE.HostingUnit> >(HostingUnitList1, BE.Tools.HostingUnitPath); return(hostUnit.HostingUnitKey); }
/// <summary> /// updates a hosting unit /// </summary> /// <param name="unit"></param> public void UpdateHostingUnit(BE.HostingUnit unit) { try { XElement toUpdate = (from item in hostingUnitRoot.Elements() where int.Parse(item.Element("HostingUnitKey").Value) == unit.HostingUnitKey select item).FirstOrDefault(); if (toUpdate == null) { throw new InvalidOperationException(string.Format("Attempt failed! hosting unit: {0} doesnt exist.", unit.HostingUnitKey)); } DeleteHostingUnit(ConvertHostingUnit(toUpdate)); AddUpdatedUnit(unit.Clone()); } catch (Exception e) { throw e; } }
// #endregion public void addHostingUnit(BE.HostingUnit hostUnit) { //אם לא הושלם מילוי if (/*hostUnit.Owner == null ||*/ hostUnit.HostingUnitName == "" || hostUnit.Owner.PrivateName == "" || hostUnit.Owner.FamilyName == "" || hostUnit.Owner.PhoneNumber == "" || hostUnit.Owner.MailAddress == null || hostUnit.Owner.BankBranchDetails == null || hostUnit.Owner.BankAccountNumber == 0) { throw new ArgumentException("חובה למלא את כל השדות"); } if (!BE.Tools.ValidateID(hostUnit.Owner.HostKey)) { throw new System.IO.InvalidDataException("תעודת זהות של מארח לא תקינה."); } if (!Enum.IsDefined(typeof(BE.AreaEnum), hostUnit.Area)) { throw new System.IO.InvalidDataException("Enum input illegal"); } if (hostUnit.Area == BE.AreaEnum.All) { throw new System.IO.InvalidDataException("Enum input illegal. HostingUnit cannot be in All regions"); } // after we cheek all the possible problems we can transfer the data to DAL layer try { IDAL.addHostingUnit(hostUnit.Clone()); } catch (DuplicateWaitObjectException e) { throw e; } // throw new NotImplementedException(); }
/// <summary> /// adds a hosting unit /// </summary> /// <param name="unit"></param> public void AddHostingUnit(BE.HostingUnit unit) { try { var it = (from item in hostingUnitRoot.Elements() where int.Parse(item.Element("HostingUnitKey").Value) == unit.HostingUnitKey select item).FirstOrDefault(); if (it != null) { throw new InvalidOperationException(string.Format("Attempt failed! hosting unit with key: {0} already exists.", unit.HostingUnitKey)); } int code = int.Parse(configRoot.Element("UnitKey").Value); unit.HostingUnitKey = code++; hostingUnitRoot.Add(xConvertHostingUnit(unit.Clone())); hostingUnitRoot.Save(HostingUnitPath); configRoot.Element("UnitKey").Value = code.ToString(); configRoot.Save(configPath); } catch (Exception e) { throw e; } }
public void UpdateHostingUnit(BE.HostingUnit hostingUnit) => _dal.UpdateHostingUnit(hostingUnit.Clone());
public void AddHostingUnit(BE.HostingUnit newHostingUnit) { // TODO in part 3: check if newHostingUnit.Owner.BankBranchDetails is exists in israel _dal.AddHostingUnit(newHostingUnit.Clone()); }