Exemplo n.º 1
0
        public async Task <ActionResult> Create(ServiceRateDto ServiceRate)
        {
            var serviceRateExists = await _serviceRateRepository.GetByComplaintsIdAsync(ServiceRate.ComplaintsId);

            if (serviceRateExists.Data == null)
            {
                var saved = await _serviceRateRepository.SaveAsync(ServiceRate);
            }
            else
            {
                serviceRateExists.Data.Rate = ServiceRate.Rate;
                var removedPreviousRate = await _serviceRateRepository.UpdateAsync(serviceRateExists.Data);
            }

            var complaints = await _complaintsRepository.GetAsync(ServiceRate.ComplaintsId);

            var binnacle = new BinnacleDto
            {
                ComplaintsId      = ServiceRate.ComplaintsId,
                StatusId          = complaints.Data.StatusId,
                Comment           = $"SE HA PUNTUADO EL TICKET COMO: {ServiceRate.Rate}",
                ApplicationUserId = User.Identity.GetUserId()
            };

            await _binnaclesRepository.SaveAsync(binnacle);

            return(RedirectToAction(nameof(ComplaintsController.Details), "Complaints", new { id = ServiceRate.ComplaintsId }));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Add(BinnacleDto binnacleDto)
        {
            var complaint = await _complaintsRepository.GetAsync(binnacleDto.ComplaintsId.GetValueOrDefault());

            var binnacle = new BinnacleDto
            {
                ApplicationUserId = User.Identity.GetUserId(),
                StatusId          = complaint.Data.StatusId,
                Comment           = binnacleDto.Comment.ToUpper(),
                ComplaintsId      = complaint.Data.Id
            };
            var binnacles = await _binnaclesRepository.SaveAsync(binnacle);

            return(Json(binnacles));
        }
        public async Task <ActionResult> Details(int id)
        {
            if (id == 0)
            {
                return(RedirectToAction(nameof(this.Index)));
            }

            var complaint = await _complaintsRepository.GetAsync(id);

            var status = await _statusRepository.GetAllAsync();

            ViewBag.StatusList = status.Data.Select(e => new SelectListItem {
                Value = e.Id.ToString(), Text = e.Name, Selected = e.Id == complaint.Data.StatusId
            }).ToList();

            var model = new ComplaintsViewModel
            {
                Complaint   = complaint,
                Binnacle    = new BinnacleDto(),
                ServiceRate = new ServiceRateDto()
            };

            return(View(model));
        }