Exemplo n.º 1
0
        public AppointmentResponse GetDoctorBasedOnPoli(AppointmentRequest request)
        {
            var response = new AppointmentResponse();
            List <PoliScheduleModel> availableSchedules = new List <PoliScheduleModel>();
            // DateTime start=new DateTime(request.Data.AppointmentDate.Year, request.Data.AppointmentDate.Month, request.Data.AppointmentDate.Day, )
            var qry = _unitOfWork.PoliScheduleRepository.Get(x => x.PoliID == request.Data.PoliID && (DbFunctions.TruncateTime(x.StartDate) <= request.Data.AppointmentDate && DbFunctions.TruncateTime(x.EndDate) >= request.Data.AppointmentDate));

            foreach (var item in qry)
            {
                availableSchedules.Add(Mapper.Map <PoliSchedule, PoliScheduleModel>(item));
            }

            var data = availableSchedules.Skip(request.Skip).Take(request.PageSize).ToList();

            response.schedules       = data;
            response.RecordsTotal    = availableSchedules.Count;
            response.RecordsFiltered = availableSchedules.Count;
            return(response);
        }
Exemplo n.º 2
0
        public AppointmentResponse SaveAppointment(AppointmentRequest request)
        {
            var response       = new AppointmentResponse();
            int resultAffected = 0;

            try
            {
                var entity = Mapper.Map <AppointmentModel, Appointment>(request.Data);
                entity.CreatedBy   = request.Data.Account.UserName;
                entity.CreatedDate = DateTime.Now;
                entity.Status      = 1;

                _unitOfWork.AppointmentRepository.Insert(entity);
                resultAffected   = _unitOfWork.Save();
                response.Status  = true;
                response.Message = Messages.DataSaved;
            }
            catch (Exception)
            {
                response.Status  = false;
                response.Message = Messages.GeneralError;
            }
            return(response);
        }
Exemplo n.º 3
0
        public AppointmentResponse Validate(AppointmentRequest request)
        {
            var  response        = new AppointmentResponse();
            bool isHavePrivilege = true;

            if (request.Data == null)
            {
                response.Status  = false;
                response.Message = "Request cannot be Null";
            }

            if (request.Data.AppointmentDate == null)
            {
                errorFields.Add("Appointment Date");
            }

            if (request.Data.ClinicID == 0)
            {
                errorFields.Add("Clinic");
            }

            if (request.Data.PoliID == 0)
            {
                errorFields.Add("Poli");
            }

            if (request.Data.DoctorID == 0)
            {
                errorFields.Add("Doctor");
            }

            if (request.Data.EmployeeID == 0)
            {
                errorFields.Add("Employee");
            }

            if (request.Data.RequirementID == 0)
            {
                errorFields.Add("Necesity");
            }

            if (errorFields.Any())
            {
                response.Status  = false;
                response.Message = string.Format(Messages.ValidationErrorFields, String.Join(",", errorFields));
            }

            isHavePrivilege = IsHaveAuthorization(ADD_PRIVILEGE_NAME, request.Data.Account.Privileges.PrivilegeIDs);
            if (!isHavePrivilege)
            {
                response.Status  = false;
                response.Message = Messages.UnauthorizedAccess;
            }

            if (response.Status)
            {
                response = new AppointmentHandler(_unitOfWork, _context).SaveAppointment(request);
            }

            return(response);
        }