public void calcAvarege(Nanny n, int count, int rate)//The nanny has a field of average ratings that ranked her, so after anyone rating her she is updated { n.averageRate = (((count - 1) * n.averageRate) + rate) / count; Idal mydal = FactoryDal.getDal(); mydal.UpdateNanny(n); }
public void RemoveHostingUnit(long hostingUnitKey) { Idal d = FactoryDal.getDal(); var result = from item in d.GetOrders() where item.HostingUnitKey == hostingUnitKey select item; if (result.Count() == 0) { foreach (var item in result) { if (item.Status == BE.Enum.OrderStatus.AnEmailWasSent) { throw new InvalidDataException("BL: Can't remove the host unit because it's currnetly open to an order"); } } } try { d.RemoveHostingUnit(hostingUnitKey); } catch (System.Exception exp) { throw exp; } }
private void addReporter() { Idal dal = FactoryDal.GetDal(); bool success = dal.AddReporter(reporter); if (success) { Signal.SuccessfullyAdded = false; Signal.SuccessfullyAdded = true; Reporter.ReporterAddress = ""; Reporter.ReporterID = 0; Reporter.ReporterName = ""; MemoryStream ms = new MemoryStream(); Image img = Image.FromFile(@"C:\Users\הילה\Desktop\Hits\Hits\blank.png"); img.Save(ms, img.RawFormat); Reporter.ReporterProfilePicture = ms.ToArray(); } else { Signal.UnsuccessfullyAdded = false; Signal.UnsuccessfullyAdded = true; } }
public Bl_imp() { foreach (var v in FactoryDal.GetDal().GetAllReport()) { int flag = 0; foreach (var h in list) { if (v.DateRep.Year - h.DateFalling.Year == 0 && v.DateRep.Month - h.DateFalling.Month == 0 && v.DateRep.Day - h.DateFalling.Day == 0 && v.DateRep.Hour - h.DateFalling.Hour == 0) { if (v.DateRep.Minute - h.DateFalling.Minute < 5 && v.DateRep.Minute - h.DateFalling.Minute > -5) { if (g.GetDistanceBetweenPoints(h.CoordinateF, v.CoordinateR) < 2) { flag = 1; } } } } //if it dosen't find an optenial fall it creat a new one with the details of the first report if (flag == 0) { Falling f = new Falling(v.City, v.Address, v.DateRep, v.CoordinateR); list.Add(f); } } }
static void Main(string[] args) { IDataLayer <CustomerBase> dalcust = FactoryDal <CustomerBase> .getDal("EfCustDal"); IDataLayer <AddressBase> daladd = FactoryDal <AddressBase> .getDal("EfAddDal"); IDataLayer <PhoneBase> dalphone = FactoryDal <PhoneBase> .getDal("EfPhoneDal"); Mediator.Mediator obj = new Mediator.Mediator(dalcust, daladd, dalphone); CustomerBase c = Factory <CustomerBase> .Create("Customer"); c.CustomerName = "tesy123"; c.PhoneNumber = "90909"; c.BillDate = Convert.ToDateTime("1/1/2010"); c.Type = "Customer"; c.BillAmount = 100; obj.Add(c); AddressBase a = Factory <AddressBase> .Create("Address"); a.Address1 = "Mulund"; obj.Add(a); PhoneBase p = Factory <PhoneBase> .Create("Phone"); p.PhoneNumber = "222"; obj.Add(p, 0); obj.SaveAll(); }
public void RemoveHost(Host host) { Idal d = FactoryDal.getDal(); var result = from item1 in d.GetHostingUnitCopy()//result saves all the hosting units that belong the the spesific host where item1.Owner.HostKey.CompareTo(host.HostKey) == 0 select item1; foreach (var item2 in result) { var result2 = from item in d.GetOrders() where (item.HostingUnitKey.CompareTo(item2.HostingUnitKey) == 0 && (item.Status == BE.Enum.OrderStatus.AnEmailWasSent || item.Status == BE.Enum.OrderStatus.ClosedDueToCostumerBooked)) select item; if (result2.Count() != 0) { throw new InvalidDataException("BL: Can't remove the host because one of its units is currnetly open to an order"); } } try { d.RemoveHost(host); } catch (System.Exception exp) { throw exp; } }
public IEnumerable <HostingUnit> GetAvailableDays(DateTime date, int numOfDays) { Idal d = FactoryDal.getDal(); List <HostingUnit> hostingUnits = new List <HostingUnit>(); DateTime releaseDate = date.AddDays(numOfDays); foreach (var item in d.GetHostingUnitCopy()) { bool flag = true; for (int j = date.Day, k = date.Month; j < releaseDate.Day; j++) { if (j != 31 && item.Diary[k - 1, j - 1] == true) { flag = false; } if (j == 31 && item.Diary[k, 0] == true) { flag = false; j = 0; k++; } } if (flag) { hostingUnits.Add(item); } } if (hostingUnits.Count() == 0) { throw new ArgumentNullException("BL: There isn't any hosting units which are available in the required dates"); } return(hostingUnits); }
public void DeleteChild(Child newchild) { DeleteContract(GetContractByChild(newchild)); //delete the contract with this child, if exist Idal mydal = FactoryDal.getDal(); mydal.DeleteChild(newchild); //send to lower layer DAL }
public void AddChild(Child newchild) { //call DAL for action Idal mydal = FactoryDal.getDal(); mydal.AddChild(newchild); }
public void ResetOrders() { Idal d = FactoryDal.getDal(); //AmountOfOrders(d.UpdateStatus); d.UpdateStatus(); }
private void LoadGrid() { IRepository <CustomerBase> iDal = FactoryDal <IRepository <CustomerBase> > .Create(cmbDal.Text); List <CustomerBase> custs = iDal.Search(); dgvCustomers.DataSource = custs; }
public CompraBiz(DateTime fecha) { this.proveedorDal = FactoryDal <ProveedorDal> .GetDal(); var aniomes = fecha.Year * 100 + fecha.Month; this.compraDal = FactoryDalWithNumber <CompraDal> .GetDal(aniomes); }
private void ShownReportslist() { ShownReports.Clear(); foreach (Report report in FactoryDal.GetDal().GetReports()) { ShownReports.Add(report); } }
private MyBL() { d = FactoryDal.getDal(); if (d.getTestersList().ToList().Count == 0) { InitialFields(); } }
private void fillReports() { tempReportsToShow.Clear(); foreach (Report report in FactoryDal.GetDal().GetReports()) { tempReportsToShow.Add(report); } }
public void UpdateOrder(Order order) { if (order.Status == BE.Enum.OrderStatus.AnEmailWasSent) { Idal d = FactoryDal.getDal(); var result2 = from item in d.GetGuests() let help = order.GuestRequestKey where item.GuestRequestKey == help select(GuestRequest) item; int amountOfTotalDays = (int)(result2.Single().ReleaseDate - result2.Single().EntryDate).TotalDays; Configuration.gains = Configuration.gains + amountOfTotalDays * Configuration.fee; bool flag = true; DateTime temp = result2.Single().EntryDate; int k = result2.Single().EntryDate.Month; int t = 0; for (DateTime l = result2.Single().EntryDate; l < result2.Single().ReleaseDate; l = l.AddDays(1)) { if (l.Day != 31 && (d.GetHostingUnitCopy().First(x => x.HostingUnitKey == order.HostingUnitKey)).Diary[l.Day - 1, k - 1] == true) { flag = false; } if (l.Day == 31 && (d.GetHostingUnitCopy().First(x => x.HostingUnitKey == order.HostingUnitKey)).Diary[0, k] == true) { t++; flag = false; l = temp.AddDays(k); k++; } } if (flag == false) { throw new InvalidDataException("BL: Couldn't update the dates because the dates were already occupied"); } d.GetGuests().First(x => x.GuestRequestKey == order.GuestRequestKey).Status = BE.Enum.CustomerOrderStatus.ClosedThroughWebsite; HostingUnit hostingUnit = d.GetHostingUnitCopy().First(x => x.HostingUnitKey == order.HostingUnitKey); DateTime temp2 = result2.Single().EntryDate; int j = 0; for (DateTime n = temp; j <= amountOfTotalDays; n = n.AddDays(1), j++) // updates the array with the required days { hostingUnit.Diary[n.Day - 1, k - 1] = true; } d.UpdateHostingUnit(hostingUnit); d.GetOrders().First(x => x.OrderKey == order.OrderKey).Status = BE.Enum.OrderStatus.ClosedDueToCostumerResponse; try { d.UpdateOrder(d.GetOrders().First(x => x.OrderKey == order.OrderKey)); } catch (System.Exception) { throw new DataException("BL: Cannot update the order due to an error in the information"); } } else { throw new InvalidDataException("BL: Can't update the order because it's already closed"); } }
public IEnumerable <IGrouping <int, Host> > GetAllHostsGruopByAmountOfHostingUnits() { Idal d = FactoryDal.getDal(); return(from item in d.GetHosts() let amount = item.amountOfHostingUnits group item by amount into g select g); }
public List <Nanny> Tamat()//returns list of all nannies that their vacation days are by the Tamt office { Idal mydal = FactoryDal.getDal(); List <Nanny> NannysVacations = (from n in mydal.GetNannysList() where n.VacationDays //all the nannies that their vacation days are by the Tamt office select n).ToList(); return(NannysVacations); }
public List <Child> ChildWithoutNanny()//returns list of all child that don't have nanny { Idal mydal = FactoryDal.getDal(); List <Child> ChildWithoutNanny = (from child in mydal.GetChildsList() where !(mydal.GetContractsList().ToList().Exists(co => co.ChildID == child.ID)) //all the childerns that dont have contract->dont have nanny select child).ToList(); return(ChildWithoutNanny); }
private void btnAdd_Click(object sender, EventArgs e) { IRepository <CustomerBase> dal = FactoryDal <IRepository <CustomerBase> > .Create(cmbDal.Text); SetCustomer(); dal.Add(cust); //In memory Addition. dal.Save(); //Physical Commit. LoadGrid(); }
public List <Contract> SelectedContracts(Predicate <Contract> cond)//Returns all contracts that fulfill the condition { Idal mydal = FactoryDal.getDal(); List <Contract> SelectedContracts = (from contract in mydal.GetContractsList() where cond(contract) //all the contracts that fulfill the condition select contract).ToList(); return(SelectedContracts); }
public List <Mother> SelectedMothers(String motherID)//returns list of mothers that close to specific mother { Idal mydal = FactoryDal.getDal(); Mother specificMother = mydal.GetMothersList().ToList().Find(m => m.ID == motherID); List <Mother> Selectedmothers = (from mother in mydal.GetMothersList() where Distance(mother.PersonAddress, specificMother.PersonAddress) < 0.250 //checks for each mother if she close to the specific mother in a distance less than 250 meter select mother).ToList(); return(Selectedmothers); }
public IEnumerable <GuestRequest> GetGuests() { Idal d = FactoryDal.getDal(); if (d.GetGuests().Count() == 0) { throw new ArgumentNullException("BL: Couldn't return guests request because its list is empty"); } return(d.GetGuests()); }
public ProductoBiz() { this.productoDal = FactoryDal <ProductoDal> .GetDal(); this.materiaPrimaDal = FactoryDal <MateriaPrimaDal> .GetDal(); this.marcaDal = FactoryDal <MarcaDal> .GetDal(); this.unidadMedidaBiz = new UnidadMedidaBiz(); }
public IEnumerable <Order> GetOrders() { Idal d = FactoryDal.getDal(); if (d.GetOrders() == null) { throw new ArgumentNullException("BL: Couldn't return guests request because its list is empty"); } return(d.GetOrders()); }
public List <BankBranch> GetBankBranches() { Idal d = FactoryDal.getDal(); if (d.GetBankBranches().Count() == 0) { throw new ArgumentNullException("BL: Couldn't return bank branches because its list is empty"); } return(d.GetBankBranches()); }
private void fetchReport() { Idal dal = FactoryDal.GetDal(); oldReport = dal.GetReport(updatedReport.ReportID); UpdatedReport.NewCoordinates = oldReport.LatLongLocation; UpdatedReport.NewTime = oldReport.FallingTime; UpdatedReport.NumberOfHits = oldReport.NumberOfBooms; }
public List <Report> GetAllReport() { List <Report> MyList = new List <Report>(); foreach (var v in FactoryDal.GetDal().GetAllReport()) { MyList.Add(v); } return(MyList); }
public List <Falling> GetAllFalling() { List <Falling> MyList = new List <Falling>(); foreach (var v in FactoryDal.GetDal().GetAllFalling()) { MyList.Add(v); } return(MyList); }
public IEnumerable <HostingUnit> GetHostingUnitCopy() { Idal d = FactoryDal.getDal(); if (d.GetHostingUnitCopy().Count() == 0) { throw new ArgumentNullException("BL: Couldn't return hosting unit because its list is empty"); } return(d.GetHostingUnitCopy()); }