예제 #1
0
        public SchedulingEntity[] GetSchedulingCompany(int companyId, int schedulingId = 0)
        {
            List <SchedulingEntity> arrayOfSchedulingEntity = new List <SchedulingEntity>();

            using (Petz_dbEntities db = new Petz_dbEntities())
            {
                var petScheduling = (from s in db.petz_Pet_Scheduling
                                     join a in db.petz_Company_Address on s.company_address_id equals a.company_address_id
                                     where a.company_id == companyId &&
                                     s.scheduling_date_start >= _filterStart &&
                                     s.scheduling_date_start <= _filterEnd &&
                                     s.scheduling_id == (schedulingId == 0 ? s.scheduling_id : schedulingId)
                                     select new {
                    s.scheduling_id,
                    s.scheduling_comments,
                    s.scheduling_date_start,
                    s.scheduling_date_end,
                    s.pet_id,
                    s.client_id,
                    a.company_id,
                    a.address_id,
                    s.service_id,
                    s.employees_id,
                    s.status_id
                }
                                     ).ToArray();

                foreach (var ps in petScheduling)
                {
                    SchedulingEntity entity = new SchedulingEntity
                    {
                        Id        = ps.scheduling_id,
                        CompanyId = ps.company_id,
                        Comments  = ps.scheduling_comments,
                        DateStart = ps.scheduling_date_start,
                        DateEnd   = ps.scheduling_date_end,
                        AddressId = ps.address_id,
                        Address   = _addressController.GetAddress(ps.address_id),
                        Pet       = _petController.GetPet(ps.pet_id),
                        Client    = _clientController.GetClient(ps.client_id),
                        Status    = _statusController.GetStatusCompany(ps.company_id, ps.status_id),
                        Company   = _companyController.GetCompany(ps.company_id)
                    };


                    if (ps.service_id.HasValue)
                    {
                        entity.Service = _serviceController.GetService(ps.service_id.Value);
                    }
                    if (ps.employees_id.HasValue)
                    {
                        entity.Employee = _companyController.GetEmployees(ps.employees_id.Value);
                    }

                    arrayOfSchedulingEntity.Add(entity);
                }
            }

            return(arrayOfSchedulingEntity.ToArray());
        }
예제 #2
0
        public AddressEntity[] GetCompanyAddress(int id)
        {
            AddressController    controller  = new AddressController();
            List <AddressEntity> arrayEntity = new List <AddressEntity>();

            Petz_dbEntities db      = new Petz_dbEntities();
            var             address = db.petz_Company_Address
                                      .Where(x => x.company_id == id)
                                      .Select(x => x.address_id).ToArray();

            foreach (var a in address)
            {
                arrayEntity.Add(controller.GetAddress(a));
            }

            return(arrayEntity.ToArray());
        }