public ClientEntity[] GetCompanyClient(int id, int clientId = 0)
        {
            List <ClientEntity> arrayOfClientEntity = new List <ClientEntity>();
            ClientsController   controller          = new ClientsController();
            Petz_dbEntities     db = new Petz_dbEntities();

            int[] idsByService = (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 == id &&
                                  s.date_delete == null &&
                                  s.client_id == (clientId <= 0 ? s.client_id : clientId)
                                  select s.client_id)
                                 .Distinct()
                                 .ToArray();
            int[] idsByFavorite = db.petz_Client_Company
                                  .Where(x => x.company_id == id &&
                                         x.client_id == (clientId <= 0 ? x.client_id : clientId))
                                  .Select(x => x.client_id)
                                  .Distinct()
                                  .ToArray();
            int[] ids = idsByService.Concat(idsByFavorite)
                        .Distinct()
                        .ToArray();
            foreach (int i in ids)
            {
                arrayOfClientEntity.Add(controller.GetClient(i));
            }

            return(arrayOfClientEntity.ToArray());
        }
Beispiel #2
0
        public RatingHistoric[] GetPetRatingHistoric(int id)
        {
            ClientsController controller = new ClientsController();

            return(GetPetRating(id)
                   .Select(x => new RatingHistoric()
            {
                Comments = x.Comments,
                Date = x.Date,
                Id = x.Id,
                InsertByName = controller.GetClient(x.InsertByClientId).Name,
                RatingValue = x.RatingValue
            }).ToArray());
        }
Beispiel #3
0
        public ClientEntity GetClient(int id)
        {
            ClientsController controller = new ClientsController();

            return(controller.GetClient(id));
        }