public GetExcludedRoomsResponse GetExcludedRooms(int CentroId, int?OficinaId, FindRoomsListResponse listaSalas)
        {
            GetExcludedRoomsResponse response = new GetExcludedRoomsResponse();

            response.ExcludedRoomsList = new ExcludedRoomsViewModel();
            response.ExcludedRoomsList.ExcludedRooms = new List <ExcludedRoomViewModel>();
            response.ExcludedRoomsList.CentroId      = CentroId;
            response.ExcludedRoomsList.OficinaId     = OficinaId;
            BlackListSala blackListSala;

            if (OficinaId == null)
            {
                blackListSala = _blackListSalasRepository.GetOne(x => x.IsActivo && x.CentroId == CentroId && x.OficinaId == null);
            }
            else
            {
                blackListSala = _blackListSalasRepository.GetOne(x => x.IsActivo && x.CentroId == CentroId && x.OficinaId == OficinaId);
            }
            foreach (var sala in listaSalas.value)
            {
                if (blackListSala == null)
                {
                    ExcludedRoomViewModel excluded = new ExcludedRoomViewModel()
                    {
                        name     = sala.name,
                        excluded = false
                    };
                    response.ExcludedRoomsList.ExcludedRooms.Add(excluded);
                }
                else
                {
                    ExcludedRoomViewModel excluded = new ExcludedRoomViewModel()
                    {
                        name     = sala.name,
                        excluded = blackListSala.Salas.Contains(sala.name)
                    };
                    response.ExcludedRoomsList.ExcludedRooms.Add(excluded);
                }
            }

            return(response);
        }
Beispiel #2
0
        public async Task <ActionResult> ExcludedRooms(int CentroId, int?OficinaId)
        {
            GetExcludedRoomsResponse response = new GetExcludedRoomsResponse();

            try
            {
                string token         = GetNewAccessToken(CentroId);
                string nombreFiltrar = GetRoomFiltrar(CentroId, OficinaId);
                var    roomLists     = await _graphService.findRoomLists(token);

                GraphModel model = new GraphModel();

                model.Salas = new List <Sala>();

                foreach (var item in roomLists.Salas)
                {
                    if (item.Name.Contains(nombreFiltrar))
                    {
                        model.Salas.Add(item);
                    }
                }
                var listaSalas = await _graphService.FindRooms(token, model.Salas[0].Email);

                response = _graphService.GetExcludedRooms(CentroId, OficinaId, listaSalas);
                ViewBag.ExcludedRoomsList = response.ExcludedRoomsList;
                response.IsValid          = true;
            }
            catch (Exception ex)
            {
                response.IsValid      = false;
                response.ErrorMessage = ex.Message;
            }


            return(View(response.ExcludedRoomsList));
        }