Ejemplo n.º 1
0
        public ActionResult Edit(string hotelId)
        {
            //find the hotel in the repository
            // Hotel h = hotelRepo.FindByCode(hotelId);
            Hotel h = hotelRepo.FindAll().FirstOrDefault(t => t.HotelId.Equals(hotelId));

            //making the lists so that you only go to the Repo's once
            List <ContactPerson> contact = contactRepo.FindAll().OrderBy(t => t.LastName).ToList();
            List <Branch>        branch  = branchRepo.FindAll().OrderBy(t => t.Name).ToList();
            List <Owner>         owner   = ownerRepo.FindAll().OrderBy(t => t.LastName).ToList();
            List <Status>        status  = statusRepo.FindAll().OrderBy(t => t.St).ToList();

            //check if the hotel exist (normally this can never give null unless DB failure)
            if (h == null)
            {
                return(HttpNotFound());
            }

            //Use a viewmodel to display al the details of the hotel
            EditHotelViewModel ehvm = new EditHotelViewModel(h)
            {
                //select the active branch
                SelectedBranchId = branch.Where(t => t.BranchId == h.Branch.BranchId).FirstOrDefault().Name,
                //fill the list with all the branches
                Branch = branch.Select(t => new SelectListItem
                {
                    Value = t.BranchId.ToString(),
                    Text  = t.Name
                }),
                //repeat for al the other lists

                //Contactperson
                //it doesn't matter with the selectedId if you use the id of the name
                SelectedContactPersonId = contact.Where(t => t.ContactPersonId == h.ContactPerson.ContactPersonId).FirstOrDefault().ContactPersonId.ToString(),
                ContactPerson           = contact.Select(t => new SelectListItem
                {
                    Value = t.ContactPersonId.ToString(),
                    Text  = t.LastName + " " + t.FirstName
                }),

                //Owner
                SelectedOwnerId = owner.Where(t => t.OwnerId == h.Owner.OwnerId).FirstOrDefault().OwnerId.ToString(),
                Owner           = owner.Select(t => new SelectListItem
                {
                    Value = t.OwnerId.ToString(),
                    Text  = t.LastName + " " + t.FirstName
                }),

                //status
                SelectedStatusId = status.Where(t => t.St == h.Status.St).FirstOrDefault().ToString(),
                Status           = status.Select(t => new SelectListItem
                {
                    Value = t.St,
                    Text  = t.St
                })
            };

            return(View(ehvm));
        }
        public async Task <PagedList <StatusDto> > Search(PaginationParams param, object text)
        {
            var lists = _repoStatus.FindAll().ProjectTo <StatusDto>(_configMapper)
                        .Where(x => x.Name.Contains(text.ToString()))
                        .OrderByDescending(x => x.StatusID);

            return(await PagedList <StatusDto> .CreateAsync(lists, param.PageNumber, param.PageSize));
        }
Ejemplo n.º 3
0
        public async Task <StatusListResponse> GetStatusesAsync(StatusListRequest request)
        {
            await ValidateRequestAsync(request);

            var entities = _statusRepository.FindAll().ToList();

            return(_mapper.Map <StatusListResponse>(entities));
        }
    public ActionResult YourAction()
    {
        YourViewModel viewModel = new YourViewModel
        {
            Statuses = statusRepository.FindAll()
        };

        return(View(viewModel));
    }
Ejemplo n.º 5
0
        public IActionResult Get()
        {
            try
            {
                List <StatusConsultaViewModel> lista = new List <StatusConsultaViewModel>();

                foreach (var s in repository.FindAll())
                {
                    var model = Mapper.Map <StatusConsultaViewModel>(s);

                    lista.Add(model);
                }

                return(Ok(lista));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Ejemplo n.º 6
0
        public List <StatusViewModel> SelectAll()
        {
            var status = _repo.FindAll(x => x.Deleted == false);

            return(_mapper.Map <List <StatusViewModel> >(status));
        }
Ejemplo n.º 7
0
 public List <Status> GetStatusActives()
 {
     return(_repoStatus.FindAll(x => x.Description != "ARQUIVADO" && x.Description != "APAGADO").ToList());
 }
Ejemplo n.º 8
0
 public ICollection <StatusModel> FindAll()
 {
     return(_repository.FindAll());
 }
Ejemplo n.º 9
0
 public JsonResult GetViewData()
 {
     return(Json(_statusRepository.FindAll()));
 }
Ejemplo n.º 10
0
        // GET: Settings
        public ActionResult Index()
        {
            SettingsViewModel svm = new SettingsViewModel(branchRepo.FindAll().ToList(), contactRepo.FindAll().ToList(), ownerRepo.FindAll().ToList(), statusRepo.FindAll().ToList());

            return(View(svm));
        }