Exemplo n.º 1
0
        public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity)
        {
            BO.UserCompany usercompanyBO = (BO.UserCompany)(object) entity;
            BO.Company     companyBO     = usercompanyBO.Company;
            BO.User        userBO        = usercompanyBO.User;


            var result = usercompanyBO.Validate(companyBO);

            return(result);
        }
Exemplo n.º 2
0
 public override Object GetByUserId(int UserId)
 {
     BO.UserCompany acc_ = Convert <BO.UserCompany, UserCompany>(_context.UserCompanies.Include("User").Include("Company").Where(p => p.UserID == UserId).FirstOrDefault <UserCompany>());
     if (acc_ == null)
     {
         return(acc_);
     }
     else
     {
         return(acc_);
     }
 }
Exemplo n.º 3
0
 public override Object Get(int id)
 {
     BO.UserCompany acc_ = Convert <BO.UserCompany, UserCompany>(_context.UserCompanies.Include("User").Include("Company").Where(p => p.id == id && p.IsAccepted == true && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault <UserCompany>());
     if (acc_ == null)
     {
         return(acc_);
     }
     else
     {
         return(acc_);
     }
 }
Exemplo n.º 4
0
        public override Object Delete <T>(T entity)
        {
            BO.UserCompany usercompanyBO = entity as BO.UserCompany;

            UserCompany usercompanyDB = new UserCompany();

            usercompanyDB.id = usercompanyBO.ID;
            _dbSet.Remove(_context.UserCompanies.Single <UserCompany>(p => p.id == usercompanyBO.ID));
            _context.SaveChanges();

            var res = (BO.GbObject)(object) entity;

            return(usercompanyDB);
        }
Exemplo n.º 5
0
        public override object Get <T>(T entity)
        {
            BO.UserCompany        usercompanyBO    = (BO.UserCompany)(object) entity;
            List <BO.UserCompany> lstUserCompanies = new List <BO.UserCompany>();
            dynamic result = null;
            var     acc_   = _context.UserCompanies.Include("User").Include("Company").Where(p => p.IsAccepted == true && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))) as IQueryable <UserCompany>;

            if (acc_ == null || acc_.Count() == 0)
            {
                return(new BO.ErrorObject {
                    ErrorMessage = "No records found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                });
            }

            if (usercompanyBO.Company != null)
            {
                if (usercompanyBO.Company.ID > 0)
                {
                    if (usercompanyBO.Company.ID > 0)
                    {
                        result = acc_.Where(x => x.Company.id == usercompanyBO.Company.ID);
                    }
                }
            }
            else if (usercompanyBO.User != null)
            {
                if (usercompanyBO.User.ID > 0)
                {
                    result = acc_.Where(x => x.User.id == usercompanyBO.User.ID);
                }
            }
            else
            {
                result = acc_;
            }
            foreach (UserCompany item in result)
            {
                lstUserCompanies.Add(Convert <BO.UserCompany, UserCompany>(item));
            }
            return(lstUserCompanies);
        }
Exemplo n.º 6
0
        public override T Convert <T, U>(U entity)
        {
            if (entity.GetType().Name != "User")
            {
                UserCompany usercompany = entity as UserCompany;

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

                BO.UserCompany usercompanyBO = new BO.UserCompany();

                usercompanyBO.ID           = usercompany.id;
                usercompanyBO.UserId       = usercompany.UserID;
                usercompanyBO.CompanyId    = usercompany.CompanyID;
                usercompanyBO.UserStatusID = (BO.GBEnums.UserStatu)usercompany.UserStatusID;
                usercompanyBO.IsAccepted   = usercompany.IsAccepted;

                if (usercompany.IsDeleted.HasValue)
                {
                    usercompanyBO.IsDeleted = usercompany.IsDeleted.Value;
                }
                if (usercompany.UpdateByUserID.HasValue)
                {
                    usercompanyBO.UpdateByUserID = usercompany.UpdateByUserID.Value;
                }

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

                if (usercompany.Company != null && (usercompany.Company.IsDeleted.HasValue == false || (usercompany.Company.IsDeleted.HasValue == true && usercompany.Company.IsDeleted.Value == false)))
                {
                    using (CompanyRepository sr = new CompanyRepository(_context))
                    {
                        BO.Company boCompany = sr.Convert <BO.Company, Company>(usercompany.Company);
                        usercompanyBO.Company = boCompany;
                    }
                }

                return((T)(object)usercompanyBO);
            }
            else
            {
                User    userDB = entity as User;
                BO.User boUser = new BO.User();

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

                if (boUser.UserCompanies == null && userDB.UserCompanies != null)
                {
                    boUser.UserCompanies = new List <BO.UserCompany>();

                    foreach (var eachUserCompany in userDB.UserCompanies)
                    {
                        if (eachUserCompany.IsDeleted.HasValue == false || (eachUserCompany.IsDeleted.HasValue == true && eachUserCompany.IsDeleted.Value == false))
                        {
                            BO.UserCompany usercompanyBO = new BO.UserCompany();

                            usercompanyBO.ID        = eachUserCompany.id;
                            usercompanyBO.UserId    = eachUserCompany.UserID;
                            usercompanyBO.CompanyId = eachUserCompany.CompanyID;

                            usercompanyBO.IsDeleted      = eachUserCompany.IsDeleted;
                            usercompanyBO.CreateByUserID = eachUserCompany.CreateByUserID;
                            usercompanyBO.UpdateByUserID = eachUserCompany.UpdateByUserID;
                            usercompanyBO.IsAccepted     = true;

                            boUser.UserCompanies.Add(usercompanyBO);
                        }
                    }
                }

                return((T)(object)boUser);
            }
        }
Exemplo n.º 7
0
        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);
        }