예제 #1
0
파일: BL_imp.cs 프로젝트: ReutAttar/Project
        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);
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
파일: Bl_imp.cs 프로젝트: am122131/Missile
        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);
                }
            }
        }
예제 #5
0
        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();
        }
예제 #6
0
        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;
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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
        }
예제 #9
0
        public void AddChild(Child newchild)
        {
            //call DAL for action
            Idal mydal = FactoryDal.getDal();

            mydal.AddChild(newchild);
        }
예제 #10
0
        public void ResetOrders()
        {
            Idal d = FactoryDal.getDal();

            //AmountOfOrders(d.UpdateStatus);
            d.UpdateStatus();
        }
예제 #11
0
        private void LoadGrid()
        {
            IRepository <CustomerBase> iDal = FactoryDal <IRepository <CustomerBase> > .Create(cmbDal.Text);

            List <CustomerBase> custs = iDal.Search();

            dgvCustomers.DataSource = custs;
        }
예제 #12
0
        public CompraBiz(DateTime fecha)
        {
            this.proveedorDal = FactoryDal <ProveedorDal> .GetDal();

            var aniomes = fecha.Year * 100 + fecha.Month;

            this.compraDal = FactoryDalWithNumber <CompraDal> .GetDal(aniomes);
        }
예제 #13
0
 private void ShownReportslist()
 {
     ShownReports.Clear();
     foreach (Report report in FactoryDal.GetDal().GetReports())
     {
         ShownReports.Add(report);
     }
 }
예제 #14
0
 private MyBL()
 {
     d = FactoryDal.getDal();
     if (d.getTestersList().ToList().Count == 0)
     {
         InitialFields();
     }
 }
예제 #15
0
 private void fillReports()
 {
     tempReportsToShow.Clear();
     foreach (Report report in FactoryDal.GetDal().GetReports())
     {
         tempReportsToShow.Add(report);
     }
 }
예제 #16
0
        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");
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
파일: BL_imp.cs 프로젝트: ReutAttar/Project
        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);
        }
예제 #19
0
파일: BL_imp.cs 프로젝트: ReutAttar/Project
        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);
        }
예제 #20
0
        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();
        }
예제 #21
0
파일: BL_imp.cs 프로젝트: ReutAttar/Project
        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);
        }
예제 #22
0
파일: BL_imp.cs 프로젝트: ReutAttar/Project
        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);
        }
예제 #23
0
        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());
        }
예제 #24
0
        public ProductoBiz()
        {
            this.productoDal = FactoryDal <ProductoDal> .GetDal();

            this.materiaPrimaDal = FactoryDal <MateriaPrimaDal> .GetDal();

            this.marcaDal = FactoryDal <MarcaDal> .GetDal();

            this.unidadMedidaBiz = new UnidadMedidaBiz();
        }
예제 #25
0
        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());
        }
예제 #26
0
        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());
        }
예제 #27
0
        private void fetchReport()
        {
            Idal dal = FactoryDal.GetDal();

            oldReport = dal.GetReport(updatedReport.ReportID);

            UpdatedReport.NewCoordinates = oldReport.LatLongLocation;
            UpdatedReport.NewTime        = oldReport.FallingTime;
            UpdatedReport.NumberOfHits   = oldReport.NumberOfBooms;
        }
예제 #28
0
파일: Bl_imp.cs 프로젝트: am122131/Missile
        public List <Report> GetAllReport()
        {
            List <Report> MyList = new List <Report>();

            foreach (var v in FactoryDal.GetDal().GetAllReport())
            {
                MyList.Add(v);
            }
            return(MyList);
        }
예제 #29
0
파일: Bl_imp.cs 프로젝트: am122131/Missile
        public List <Falling> GetAllFalling()
        {
            List <Falling> MyList = new List <Falling>();

            foreach (var v in FactoryDal.GetDal().GetAllFalling())
            {
                MyList.Add(v);
            }
            return(MyList);
        }
예제 #30
0
        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());
        }