public void Should_Map_CalendarDto_to_Calendar()
        {
            // Arrange
            var _mCalendar = new Mock <Calendar>();

            var calendarDto = new CalendarDto
            {
                IsActive  = true,
                StartDate = _testDateTime,
                EndDate   = _testDateTime,
                Name      = _testNameString,
                SiteId    = 1,
                SubSiteId = 1
            };

            // Act
            CommonHelperAppService.MapDtoToEntityForUpdating(calendarDto, _mCalendar.Object);

            // Assert
            Assert.AreEqual(calendarDto.IsActive, _mCalendar.Object.IsActive);
            Assert.AreEqual(calendarDto.StartDate, _mCalendar.Object.StartDate);
            Assert.AreEqual(calendarDto.EndDate, _mCalendar.Object.EndDate);
            Assert.AreEqual(calendarDto.Name, _mCalendar.Object.Name);
            Assert.AreEqual(calendarDto.SiteId, _mCalendar.Object.SiteId);
            Assert.AreEqual(calendarDto.SubSiteId, _mCalendar.Object.SubSiteId);
        }
Пример #2
0
        public CalendarDto UpdateCalendar(CalendarDto calendarDto)
        {
            var calendar = _unitOfWork.Context.GetDbSet <Calendar>().FirstOrDefault(x => x.Id == calendarDto.Id);

            calendar = _mapper.Map <CalendarDto, Calendar>(calendarDto);
            _unitOfWork.Context.SaveChanges();
            return(_mapper.Map <CalendarDto>(calendar));
        }
Пример #3
0
 public static void MapDtoToEntityForUpdating(CalendarDto calendarDto, Calendar calendar)
 {
     calendar.IsActive  = calendarDto.IsActive;
     calendar.Name      = calendarDto.Name;
     calendar.StartDate = calendarDto.StartDate;
     calendar.EndDate   = calendarDto.EndDate;
     calendar.SiteId    = calendarDto.SiteId;
     calendar.SubSiteId = calendarDto.SubSiteId;
 }
        public async Task HomeIndex()
        {
            HomeController controller = DependencyResolver.Current.GetService <HomeController>();
            ViewResult     result     = await controller.Index(new DateTime( 2018, 4, 1 )) as ViewResult;

            CalendarDto model = result.Model as CalendarDto;

            Assert.IsNotNull(model);
        }
Пример #5
0
        public Task <string> GetGoogleCalendarLinkAsync(CalendarDto calendarDto)
        {
            var link = $"{Constants.GoogleUrl}" +
                       $"?action=TEMPLATE&text={calendarDto.Text}" +
                       $"&dates={calendarDto.Start.ToLocalString()}" +
                       $"/{calendarDto.End.ToLocalString()}" +
                       $"&details={calendarDto.Details}" +
                       $"&location={calendarDto.Location}";

            return(Task.FromResult(link));
        }
Пример #6
0
        public async Task <IActionResult> GetReleaseCalendarAsync()
        {
            var calendarDto = new CalendarDto
            {
                Items = (await _movieService.GetMovieCalendarAsync()).Concat(
                    await _tvShowService.GetTvShowCalendarAsync()),
                DateRange = new Tuple <DateTime, DateTime>(DateTime.Now, DateTime.Now.AddMonths(1))
            };

            return(Ok(calendarDto));
        }
        public async Task <ActionResult <CalendarResponse> > GetCalendarLink(CalendarRequest calendarRequest)
        {
            CalendarDto calendarDto = _mapper.Map <CalendarDto>(calendarRequest);
            string      link        = await _calendarService.GetGoogleCalendarLinkAsync(calendarDto);

            var response = new CalendarResponse
            {
                Link = link
            };

            return(Ok(response));
        }
Пример #8
0
        public void AddCalendar(CalendarDto oCalendarDto, int nodeId, int systemUserId)
        {
            var calendarId = new Common.Utils().GetPrimaryKey(nodeId, 22, "CA");

            oCalendarDto.v_CalendarId = calendarId;

            oCalendarDto.i_IsDeleted    = (int)Enumeratores.SiNo.No;
            oCalendarDto.d_InsertDate   = DateTime.UtcNow;
            oCalendarDto.i_InsertUserId = systemUserId;

            ctx.Calendar.Add(oCalendarDto);
            ctx.SaveChanges();
        }
Пример #9
0
        /// <inheritdoc />
        public CalendarDto GetInterval(int periodId)
        {
            var current = _periodService.Get(periodId);

            if (current == null)
            {
                return(null);
            }

            var calendar = new CalendarDto
            {
                PeriodId   = current.Id,
                PeriodName = current.Name,
                Days       = new List <DayDto>()
            };
            var dayList = new List <DayDto>();

            Enum.GetValues(typeof(DayOfWeek)).Cast <DayOfWeek>().ToList().ForEach(x =>
            {
                dayList.Add(new DayDto {
                    Tiles = new List <TileDto>(), DayOfWeek = x
                });
            });

            current.Subjects.Where(x => x.IsActive).ToList().ForEach(sub =>
            {
                sub.Courses.Where(x => x.IsSelected).ToList().ForEach(cour =>
                {
                    var dayId = dayList.FindIndex(x => (int)x.DayOfWeek == cour.Day);

                    if (dayId == -1)
                    {
                        throw new ArgumentException("Invalid day");
                    }

                    dayList[dayId].Tiles.Add(new TileDto
                    {
                        CourseId         = cour.Id,
                        SubjectId        = sub.Id,
                        Place            = cour.Place,
                        SubjectShortName = sub.ShortName,
                        SubjectLongName  = sub.LongName,
                        Number           = cour.Number,
                        Length           = cour.Length
                    });
                });
            });

            calendar.Days = dayList;
            return(calendar);
        }
Пример #10
0
        // CRUD
        public void Create(CalendarDto calendarDto, long userId)
        {
            var calendar = Mapper.Map <Calendar>(calendarDto);

            _unitOfWork.CalendarRepository.Create(calendar);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeCreate,
                AppConstants.CalendarTableName,
                userId,
                calendar.Id);
        }
Пример #11
0
        public void Update(CalendarDto calendarDto, long userId)
        {
            var calendar = _unitOfWork.CalendarRepository.GetById(calendarDto.Id);

            CommonHelperAppService.MapDtoToEntityForUpdating(calendarDto, calendar);

            _unitOfWork.CalendarRepository.Update(calendar);
            _unitOfWork.Save();

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeUpdate,
                AppConstants.CalendarTableName,
                userId,
                calendar.Id);
        }
Пример #12
0
        public CalendarDto AddCalendar(CalendarDto calendarDto)
        {
            var calendar = new Calendar();

            try
            {
                calendar = _mapper.Map <CalendarDto, Calendar>(calendarDto);
                _unitOfWork.Context.GetDbSet <Calendar>().Add(calendar);
                _unitOfWork.Context.SaveChanges();
            }
            catch (Exception ex)
            {
                _log.Error(ex);
            }

            return(_mapper.Map <CalendarDto>(calendar));
        }
Пример #13
0
        public string Schedule(CalendarDto oCalendarDto, int nodeId, int systemUserId)
        {
            //using (var ts = new TransactionScope())
            //{
            var oServiceDto = PopulateServiceDto(oCalendarDto);

            var serviceId = new ServiceDal().AddService(oServiceDto, nodeId, systemUserId);

            AddServiceComponentInBlock(serviceId, oCalendarDto.v_ProtocolId, oCalendarDto.v_PersonId, nodeId,
                                       systemUserId);

            oCalendarDto.v_ServiceId = serviceId;
            AddCalendar(oCalendarDto, nodeId, systemUserId);

            return(serviceId);

            //}
        }
Пример #14
0
        public string ScheduleMedicalConsultation(ScheduleCustom oScheduleCustom, int nodeId, int systemUserId)
        {
            if (oScheduleCustom.TypeId == (int)Enumeratores.TypeSchedule.AgendadoIniciado)
            {
                var oCalendarDto = new CalendarDto();
                oCalendarDto.v_PersonId          = oScheduleCustom.PersonId;
                oCalendarDto.v_ProtocolId        = Constants.PROTOCOL_VIGILANCIA;
                oCalendarDto.d_DateTimeCalendar  = DateTime.Now;
                oCalendarDto.d_CircuitStartDate  = DateTime.Now;
                oCalendarDto.d_EntryTimeCM       = DateTime.Now;
                oCalendarDto.i_ServiceTypeId     = (int)Enumeratores.masterService.AtxMedicaParticular;
                oCalendarDto.i_CalendarStatusId  = (int)Enumeratores.CalendarStatus.Atendido;
                oCalendarDto.i_ServiceId         = (int)Enumeratores.masterService.AtxMedicaParticular;
                oCalendarDto.i_NewContinuationId = (int)Enumeratores.Modality.NuevoServicio;
                oCalendarDto.i_LineStatusId      = (int)Enumeratores.LineStatus.EnCircuito;
                oCalendarDto.i_IsVipId           = (int)Enumeratores.SiNo.No;

                return(new SchedulePersonDal().Schedule(oCalendarDto, nodeId, systemUserId));
            }
            else
            {
                var oCalendarDto = new CalendarDto();
                oCalendarDto.v_PersonId          = oScheduleCustom.PersonId;
                oCalendarDto.v_ProtocolId        = Constants.PROTOCOL_VIGILANCIA;
                oCalendarDto.d_DateTimeCalendar  = oScheduleCustom.ScheduleDate;
                oCalendarDto.d_CircuitStartDate  = null;
                oCalendarDto.d_EntryTimeCM       = null;
                oCalendarDto.i_ServiceTypeId     = (int)Enumeratores.masterService.AtxMedicaParticular;
                oCalendarDto.i_CalendarStatusId  = (int)Enumeratores.CalendarStatus.Agendado;
                oCalendarDto.i_ServiceId         = (int)Enumeratores.masterService.AtxMedicaParticular;
                oCalendarDto.i_NewContinuationId = (int)Enumeratores.Modality.NuevoServicio;
                oCalendarDto.i_LineStatusId      = (int)Enumeratores.LineStatus.FueraCircuito;
                oCalendarDto.i_IsVipId           = (int)Enumeratores.SiNo.No;

                var serviceId = new SchedulePersonDal().Schedule(oCalendarDto, nodeId, systemUserId);

                var oVigilanciaServiceDto = new VigilanciaServiceDto();
                oVigilanciaServiceDto.v_ServiceId    = serviceId;
                oVigilanciaServiceDto.v_Commentary   = oScheduleCustom.Commentary;
                oVigilanciaServiceDto.v_VigilanciaId = oScheduleCustom.VigilanciId;
                new VigilanciaDal().AddVigilanciaService(oVigilanciaServiceDto, nodeId, systemUserId);
                return(serviceId);
            }
        }
Пример #15
0
        private ServiceDto PopulateServiceDto(CalendarDto oCalendarDto)
        {
            var oServiceDto = new ServiceDto
            {
                v_ProtocolId           = oCalendarDto.v_ProtocolId,
                v_PersonId             = oCalendarDto.v_PersonId,
                i_MasterServiceId      = (int)oCalendarDto.i_ServiceId,
                i_ServiceStatusId      = (int)Enumeratores.ServiceStatus.PorIniciar,
                i_AptitudeStatusId     = (int)Enumeratores.AptitudeStatus.SinAptitud,
                d_ServiceDate          = oCalendarDto.d_DateTimeCalendar,
                d_GlobalExpirationDate = null,
                d_ObsExpirationDate    = null,
                i_FlagAgentId          = 1,
                v_Motive = string.Empty,
                i_IsFac  = (int)Enumeratores.SiNo.No
            };

            return(oServiceDto);
        }
Пример #16
0
        private CalendarDto PopulateCalendarDtoSurveillance(string serviceId, string personId, string protocolId)
        {
            var oCalendarDto = new CalendarDto();

            oCalendarDto.v_ServiceId = serviceId;
            oCalendarDto.v_PersonId  = personId;
            //oCalendarDto.d_DateTimeCalendar = DateTime.Now;
            //oCalendarDto.d_CircuitStartDate = DateTime.Now;
            //oCalendarDto.d_EntryTimeCM = DateTime.Now;
            oCalendarDto.i_ServiceTypeId     = (int)Enumeratores.masterService.AtxMedica;
            oCalendarDto.i_CalendarStatusId  = (int)Enumeratores.CalendarStatus.Atendido;
            oCalendarDto.i_ServiceId         = (int)Enumeratores.masterService.AtxMedicaParticular;
            oCalendarDto.v_ProtocolId        = protocolId;
            oCalendarDto.i_NewContinuationId = (int)Enumeratores.Modality.NuevoServicio;
            oCalendarDto.i_LineStatusId      = (int)Enumeratores.LineStatus.EnCircuito;
            oCalendarDto.i_IsVipId           = (int)Enumeratores.SiNo.No;

            return(oCalendarDto);
        }
Пример #17
0
        public bool AddCalendar(CalendarDto oCalendarDto, int nodeId, int systemUserId)
        {
            try
            {
                var calendarId = new Common.Utils().GetPrimaryKey(nodeId, 22, "CA");

                oCalendarDto.v_CalendarId = calendarId;

                oCalendarDto.i_IsDeleted    = (int)SiNo.No;
                oCalendarDto.d_InsertDate   = DateTime.UtcNow;
                oCalendarDto.i_InsertUserId = systemUserId;

                ctx.Calendar.Add(oCalendarDto);
                return(ctx.SaveChanges() > 0);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #18
0
 private void AddCalendar(CalendarDto oCalendarDto, int nodeId, int systemUserId)
 {
     //var oCalendarDto = PopulateCalendarDtoSurveillance(serviceId, personId, protocolId);
     new CalendarDal().AddCalendar(oCalendarDto, nodeId, systemUserId);
 }
Пример #19
0
 /// <summary>
 /// Sets custom calendar, with excluded dates in UTC, for current tenant
 /// </summary>
 /// <remarks>
 /// Required permissions: Settings.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='calendar'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task SetCalendarAsync(this ISettings operations, CalendarDto calendar, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     (await operations.SetCalendarWithHttpMessagesAsync(calendar, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Пример #20
0
 /// <summary>
 /// Sets custom calendar, with excluded dates in UTC, for current tenant
 /// </summary>
 /// <remarks>
 /// Required permissions: Settings.Edit.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='calendar'>
 /// </param>
 public static void SetCalendar(this ISettings operations, CalendarDto calendar)
 {
     operations.SetCalendarAsync(calendar).GetAwaiter().GetResult();
 }
Пример #21
0
        public bool SaveAdditionalExamsForCalendar(List <AdditionalExamCreate> data, int userId, int nodeId)
        {
            try
            {
                DatabaseContext dbContext = new DatabaseContext();
                using (var ts = new TransactionScope())
                {
                    foreach (var objExam in data)
                    {
                        if (objExam.IsNewService == (int)SiNo.No)
                        {
                            var unidadProductiva = GetMedicalExam(objExam.ComponentId);
                            var newId            = new Common.Utils().GetPrimaryKey(nodeId, 24, "SC");;
                            ServiceComponentDto objServiceComponentDto = new ServiceComponentDto();
                            objServiceComponentDto.v_ServiceComponentId     = newId;
                            objServiceComponentDto.i_ConCargoA              = -1;
                            objServiceComponentDto.v_ServiceId              = objExam.ServiceId;
                            objServiceComponentDto.i_ExternalInternalId     = (int)ComponenteProcedencia.Interno;
                            objServiceComponentDto.i_ServiceComponentTypeId = 1;
                            objServiceComponentDto.i_IsVisibleId            = 1;
                            objServiceComponentDto.i_IsInheritedId          = (int)SiNo.No;
                            objServiceComponentDto.d_StartDate              = null;
                            objServiceComponentDto.d_EndDate                  = null;
                            objServiceComponentDto.i_index                    = 1;
                            objServiceComponentDto.r_Price                    = objExam.Price;
                            objServiceComponentDto.v_ComponentId              = objExam.ComponentId;
                            objServiceComponentDto.i_IsInvoicedId             = (int)SiNo.No;
                            objServiceComponentDto.i_ServiceComponentStatusId = (int)ServiceStatus.PorIniciar;
                            objServiceComponentDto.i_QueueStatusId            = (int)QueueStatusId.Libre;
                            objServiceComponentDto.i_Iscalling                = (int)Flag_Call.NoseLlamo;
                            objServiceComponentDto.i_Iscalling_1              = (int)Flag_Call.NoseLlamo;
                            objServiceComponentDto.i_IsManuallyAddedId        = (int)SiNo.No;
                            objServiceComponentDto.i_IsRequiredId             = (int)SiNo.Si;
                            objServiceComponentDto.v_IdUnidadProductiva       = unidadProductiva;
                            objServiceComponentDto.i_MedicoTratanteId         = objExam.MedicoTratante;
                            objServiceComponentDto.d_SaldoPaciente            = 0;
                            objServiceComponentDto.d_SaldoAseguradora         = 0;
                            objServiceComponentDto.i_IsDeleted                = 0;
                            objServiceComponentDto.d_InsertDate               = DateTime.Now;
                            dbContext.ServiceComponent.Add(objServiceComponentDto);
                            dbContext.SaveChanges();
                        }
                        else
                        {
                            CalendarDto _CalendarDto = new CalendarDto();
                            var         protocolId   = Constants.Prot_Hospi_Adic;
                            _CalendarDto.v_PersonId         = objExam.PersonId;
                            _CalendarDto.d_DateTimeCalendar = DateTime.Now;
                            _CalendarDto.d_CircuitStartDate = DateTime.Now;
                            _CalendarDto.d_EntryTimeCM      = DateTime.Now;
                            _CalendarDto.i_ServiceTypeId    = (int)ServiceType.Particular;
                            _CalendarDto.i_ServiceId        = (int)MasterService.Hospitalizacion;

                            _CalendarDto.i_CalendarStatusId  = (int)CalendarStatus.Agendado;
                            _CalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                            _CalendarDto.v_ProtocolId        = protocolId;
                            _CalendarDto.i_NewContinuationId = 1;
                            _CalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                            _CalendarDto.i_IsVipId           = (int)SiNo.No;

                            var result = AddCalendar(_CalendarDto, nodeId, userId);

                            if (result)
                            {
                                ServiceDto _ServiceDto = new ServiceDto();

                                _ServiceDto = ctx.Service.Where(x => x.v_ServiceId == objExam.ServiceId).FirstOrDefault();
                                _ServiceDto.d_ServiceDate     = DateTime.Now;
                                _ServiceDto.i_ServiceStatusId = (int)ServiceStatus.Iniciado;
                                _ServiceDto.d_UpdateDate      = DateTime.Now;
                                _ServiceDto.i_UpdateUserId    = userId;
                                ctx.SaveChanges();

                                var servicesComponents = new ServiceComponentDal().GetServiceComponents(objExam.ServiceId);
                                if (servicesComponents != null)
                                {
                                    foreach (var servicesComponent in servicesComponents)
                                    {
                                        var oservicecomponentDto = ctx.ServiceComponent.Where(x => x.v_ServiceComponentId == servicesComponent.v_ServiceComponentId).FirstOrDefault();
                                        oservicecomponentDto.i_MedicoTratanteId   = 11;
                                        oservicecomponentDto.i_IsVisibleId        = 1;
                                        oservicecomponentDto.v_ServiceComponentId = servicesComponent.v_ServiceComponentId;
                                        oservicecomponentDto.i_UpdateUserId       = userId;
                                        oservicecomponentDto.d_UpdateDate         = DateTime.Now;
                                        ctx.SaveChanges();
                                    }

                                    var resultHospi = new HospitalizacionDal().AddHospitalizacionService(null, objExam.ServiceId, nodeId, userId);
                                    if (!resultHospi)
                                    {
                                        throw new Exception("");
                                    }
                                }
                                else
                                {
                                    throw new Exception("");
                                }
                            }
                            else
                            {
                                throw new Exception("");
                            }
                        }
                    }

                    var resultAdditional = new AdditionalExamDal().UpdateAdditionalExamByComponentIdAndServiceId(data, userId);
                    if (!resultAdditional)
                    {
                        throw new Exception("");
                    }
                    ts.Complete();
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #22
0
        public static Calendar Mapp(this CalendarDto calendarDto)
        {
            CalendarId calendarId = new CalendarId(calendarDto.Id);

            return(new Calendar(calendarId, calendarDto.Title));
        }
Пример #23
0
        public string CreateService(ServiceCustom data, int nodeId, int userId)
        {
            string serviceId = "";
            List <ProtocolComponentCustom> ListProtocolComponent = new ProtocolComponentDal().GetProtocolComponents(data.ProtocolId);

            if (data.FechaCalendario == null)
            {
                data.ProtocolId = new ProtocolBL().ReturnOrDuplicateProtocol(data, nodeId, userId, ListProtocolComponent);
            }

            serviceId = new ServiceDal().CreateService(data, nodeId, userId);
            if (serviceId == null)
            {
                return(null);
            }



            data.ServiceId = serviceId;

            if (data.MasterServiceTypeId == (int)MasterServiceType.Empresarial)
            {
                bool result = new ServiceComponentDal().AddServiceComponent(ListProtocolComponent, data, nodeId, userId);
                if (!result)
                {
                    return(null);
                }
            }
            else
            {
                bool result = new ServiceComponentDal().AddServiceComponent(ListProtocolComponent, data, nodeId, userId);
                if (!result)
                {
                    return(null);
                }
            }

            CalendarDto _CalendarDto = new CalendarDto();

            _CalendarDto.v_PersonId          = data.PersonId;
            _CalendarDto.v_ServiceId         = data.ServiceId;
            _CalendarDto.v_PersonId          = data.PersonId;
            _CalendarDto.d_DateTimeCalendar  = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario;
            _CalendarDto.d_CircuitStartDate  = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario;
            _CalendarDto.d_EntryTimeCM       = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario;
            _CalendarDto.i_ServiceTypeId     = data.MasterServiceTypeId;
            _CalendarDto.i_CalendarStatusId  = 1;
            _CalendarDto.i_ServiceId         = data.MasterServiceId;
            _CalendarDto.v_ProtocolId        = data.ProtocolId;
            _CalendarDto.i_NewContinuationId = 1;
            _CalendarDto.i_LineStatusId      = 1;
            _CalendarDto.i_IsVipId           = 0;

            bool calendarResult = new CalendarDal().AddCalendar(_CalendarDto, nodeId, userId);

            if (!calendarResult)
            {
                return(null);
            }
            int tipoEmpresa = ProtocolDal.ObtenerTipoEmpresaByProtocol(data.ProtocolId);

            if ((data.MasterServiceId == 19 || data.MasterServiceId == 10 || data.MasterServiceId == 15 || data.MasterServiceId == 16 || data.MasterServiceId == 17 || data.MasterServiceId == 18 || data.MasterServiceId == 19) && tipoEmpresa == 4)
            {
                bool resultHospi = new HospitalizacionDal().AddHospitalizacion(data.PersonId, data.ServiceId, nodeId, userId);
                if (!resultHospi)
                {
                    return(null);
                }
            }

            return(serviceId);
        }