Beispiel #1
0
        public override Object ValidateOTP <T>(T entity)
        {
            BO.ValidateOTP validateOTP = (BO.ValidateOTP)(object) entity;


            BO.OTP  otpBO  = validateOTP.otp;
            BO.User userBO = validateOTP.user;

            OTP data_ = _context.OTPs.Where(x => x.OTP1 == otpBO.OTP1 && x.Pin == otpBO.Pin && (x.IsDeleted != true) && x.UserID == userBO.ID).FirstOrDefault();

            if (data_ == null)
            {
                return(new BO.ErrorObject {
                    ErrorMessage = "Invalid OTP", errorObject = "", ErrorLevel = ErrorLevel.Information
                });
            }
            else
            {
                BO.OTP acc_  = Convert <BO.OTP, OTP>(data_);
                User   _user = _context.Users.Where(p => p.id == data_.UserID).FirstOrDefault();
                if ((BO.GBEnums.UserType)_user.UserType == BO.GBEnums.UserType.Staff)
                {
                    using (UserCompanyRepository sr = new UserCompanyRepository(_context))
                    {
                        //acc_.company = ((BO.UserCompany)sr.Get(userBO.ID)).Company;
                        //acc_.User = ((BO.UserCompany)sr.Get(userBO.ID)).User;
                        var userCompany = ((BO.UserCompany)sr.GetByUserId(userBO.ID));
                        if (userCompany != null)
                        {
                            acc_.company = userCompany.Company;
                            acc_.User    = userCompany.User;
                        }
                    }
                }
                else
                {
                    using (UserRepository userRep = new UserRepository(_context))
                    {
                        acc_.User = ((BO.User)userRep.Get(userBO.ID));
                    }
                }
                return(acc_);
            }
        }
        public override T Convert <T, U>(U entity)
        {
            Doctor doctor = entity as Doctor;

            if (doctor == null)
            {
                return(default(T));
            }

            BO.Doctor doctorBO = new BO.Doctor();

            doctorBO.ID               = doctor.Id;
            doctorBO.LicenseNumber    = doctor.LicenseNumber;
            doctorBO.WCBAuthorization = doctor.WCBAuthorization;
            doctorBO.WcbRatingCode    = doctor.WcbRatingCode;
            doctorBO.NPI              = doctor.NPI;
            doctorBO.Title            = doctor.Title;
            doctorBO.TaxType          = (BO.GBEnums.TaxType)doctor.TaxTypeId;

            if (doctor.IsDeleted.HasValue)
            {
                doctorBO.IsDeleted = doctor.IsDeleted.Value;
            }
            if (doctor.UpdateByUserID.HasValue)
            {
                doctorBO.UpdateByUserID = doctor.UpdateByUserID.Value;
            }

            doctorBO.IsCalendarPublic = doctor.IsCalendarPublic;

            if (doctor.User != null)
            {
                if (doctor.User.IsDeleted.HasValue == false || (doctor.User.IsDeleted.HasValue == true && doctor.User.IsDeleted.Value == false))
                {
                    BO.User boUser = new BO.User();
                    using (UserRepository sr = new UserRepository(_context))
                    {
                        boUser        = sr.Convert <BO.User, User>(doctor.User);
                        doctorBO.user = boUser;
                    }

                    if (doctor.DoctorSpecialities != null)
                    {
                        List <BO.DoctorSpeciality> lstDoctorSpecility = new List <BO.DoctorSpeciality>();
                        foreach (var item in doctor.DoctorSpecialities)
                        {
                            if (item.IsDeleted == false)
                            {
                                using (DoctorSpecialityRepository sr = new DoctorSpecialityRepository(_context))
                                {
                                    lstDoctorSpecility.Add(sr.ObjectConvert <BO.DoctorSpeciality, DoctorSpeciality>(item));
                                }
                            }
                        }
                        doctorBO.DoctorSpecialities = lstDoctorSpecility;
                    }

                    if (doctor.DoctorRoomTestMappings != null)
                    {
                        List <BO.DoctorRoomTestMapping> lstDoctorRoomTestMapping = new List <BO.DoctorRoomTestMapping>();
                        foreach (var item in doctor.DoctorRoomTestMappings)
                        {
                            if (item.IsDeleted == false)
                            {
                                BO.DoctorRoomTestMapping doctorRoomTestMappingBO = new BO.DoctorRoomTestMapping();
                                doctorRoomTestMappingBO.ID        = item.Id;
                                doctorRoomTestMappingBO.IsDeleted = item.IsDeleted;
                                if (doctorRoomTestMappingBO.UpdateByUserID.HasValue)
                                {
                                    doctorRoomTestMappingBO.UpdateByUserID = item.UpdateByUserID.Value;
                                }

                                if (item.RoomTest != null && (item.RoomTest.IsDeleted.HasValue == false || (item.RoomTest.IsDeleted.HasValue == true && item.RoomTest.IsDeleted.Value == false)))
                                {
                                    BO.RoomTest boRoomTest = new BO.RoomTest();
                                    using (RoomTestRepository sr = new RoomTestRepository(_context))
                                    {
                                        boRoomTest = sr.Convert <BO.RoomTest, RoomTest>(item.RoomTest);
                                        doctorRoomTestMappingBO.RoomTest = boRoomTest;
                                    }
                                }
                                lstDoctorRoomTestMapping.Add(doctorRoomTestMappingBO);
                            }
                        }
                        doctorBO.DoctorRoomTestMappings = lstDoctorRoomTestMapping;
                    }

                    //if (doctor.User.UserCompanies != null && doctorBO.user.UserCompanies != null && doctorBO.user.UserCompanies.Count <= 0)
                    if (doctor.User.UserCompanies != null)
                    {
                        List <BO.UserCompany> lstUserCompany = new List <BO.UserCompany>();
                        foreach (var item in doctor.User.UserCompanies)
                        {
                            if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false))
                            {
                                using (UserCompanyRepository sr = new UserCompanyRepository(_context))
                                {
                                    BO.UserCompany BOUserCompany = new BO.UserCompany();
                                    BOUserCompany      = sr.Convert <BO.UserCompany, UserCompany>(item);
                                    BOUserCompany.User = null;
                                    lstUserCompany.Add(BOUserCompany);
                                }
                            }
                        }
                        doctorBO.user.UserCompanies = lstUserCompany;
                    }

                    if (doctor.DoctorLocationSchedules != null)
                    {
                        List <BO.DoctorLocationSchedule> lstDoctorLocationSchedule = new List <BO.DoctorLocationSchedule>();
                        foreach (var item in doctor.DoctorLocationSchedules)
                        {
                            if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false))
                            {
                                using (DoctorLocationScheduleRepository sr = new DoctorLocationScheduleRepository(_context))
                                {
                                    BO.DoctorLocationSchedule BODoctorLocationSchedule = new BO.DoctorLocationSchedule();
                                    BODoctorLocationSchedule          = sr.Convert <BO.DoctorLocationSchedule, DoctorLocationSchedule>(item);
                                    BODoctorLocationSchedule.doctor   = null;
                                    BODoctorLocationSchedule.schedule = null;
                                    lstDoctorLocationSchedule.Add(BODoctorLocationSchedule);
                                }
                            }
                        }
                        doctorBO.DoctorLocationSchedules = lstDoctorLocationSchedule;
                    }
                }
            }

            return((T)(object)doctorBO);
        }