public void Put([FromBody] Scheduling value)
        {
            Scheduling scheduling = _schedulingRepository.GetById(value.ID);

            scheduling.STATUS = "C";
            _schedulingRepository.Update(scheduling);
        }
        public ResponseModel UpdateSchedulingStatus(UpdateSchedulingStatusModel model)
        {
            var resp = new ResponseModel();

            try
            {
                if (model.NewStatus < 0 || (int)model.NewStatus > 1)
                {
                    resp.Message = "Novo status inválido";
                    return(resp);
                }

                Scheduling scheduling = _schedulingRepository.GetById(Guid.Parse(model.SchedulingId));
                if (scheduling == null)
                {
                    resp.Message = "Não foi possível encontrar o agendamento";
                    return(resp);
                }

                if (model.NewStatus == SchedulingStatus.Canceled)
                {
                    Policy   policy      = _schedulingRepository.GetCompanyPolicyBySchedulingId(Guid.Parse(model.SchedulingId));
                    DateTime now         = DateTimeUtil.UtcToBrasilia();
                    DateTime limitCancel = scheduling.StartTime.AddHours(-(policy.LimitCancelHours));
                    int      compare     = DateTime.Compare(now, limitCancel);
                    if (compare >= 0)
                    {
                        resp.Message = "Não é possível realizar o cancelamento." +
                                       "O Horário limite para cancelamento era: " + limitCancel;
                        return(resp);
                    }
                }

                scheduling.Status        = model.NewStatus;
                scheduling.LastUpdatedAt = DateTimeUtil.UtcToBrasilia();
                _schedulingRepository.Edit(scheduling);

                resp.Success = true;
                resp.Message = "Atualizado com sucesso";
            }
            catch (Exception)
            {
                resp.Message = "Não foi possível atualizar o status do agendamento";
            }

            return(resp);
        }
Example #3
0
        public async Task <SchedulingViewModel> GetById(int id)
        {
            var result = await _schedulingRepository.GetById(id);

            SchedulingViewModel data = _mapper.Map <SchedulingViewModel>(result);

            data.FieldItemId = data.HoraryType == Domain.Others.Enum.HoraryType.Default ? data.Horary.FieldItemId : data.HoraryExtra.FieldItemId;


            if (data.HoraryType != Domain.Others.Enum.HoraryType.Default)
            {
                data.HoraryId    = data.HoraryExtraId;
                data.FieldItemId = data.HoraryExtra.FieldItemId;
            }
            else
            {
                data.FieldItemId = data.Horary.FieldItemId;
            }

            return(data);
        }
 public async Task <Scheduling> GetById(long id)
 {
     return(await _schedulingRepository.GetById(id));
 }
 public Scheduling GetScheduling(Guid id)
 {
     return(_schedulingRepository.GetById(id));
 }