Ejemplo n.º 1
0
        public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity)
        {
            BO.Schedule schedule = (BO.Schedule)(object) entity;
            var         result   = schedule.Validate(schedule);

            return(result);
        }
Ejemplo n.º 2
0
        public override T Convert <T, U>(U entity)
        {
            Room room = entity as Room;

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

            BO.Room roomBO = new BO.Room();
            roomBO.ID               = room.id;
            roomBO.name             = room.Name;
            roomBO.contactersonName = room.ContactPersonName;
            roomBO.phone            = room.Phone;

            if (room.IsDeleted.HasValue)
            {
                roomBO.IsDeleted = room.IsDeleted.Value;
            }
            if (room.UpdateByUserID.HasValue)
            {
                roomBO.UpdateByUserID = room.UpdateByUserID.Value;
            }

            if (room.RoomTest != null)
            {
                BO.RoomTest roomtestBO = new BO.RoomTest();
                roomtestBO.name      = room.RoomTest.Name;
                roomtestBO.ID        = room.RoomTest.id;
                roomtestBO.ColorCode = room.RoomTest.ColorCode;

                if (room.RoomTest.IsDeleted.HasValue)
                {
                    roomtestBO.IsDeleted = room.RoomTest.IsDeleted.Value;
                }
                if (room.RoomTest.UpdateByUserID.HasValue)
                {
                    roomtestBO.UpdateByUserID = room.RoomTest.UpdateByUserID.Value;
                }
                roomBO.roomTest = roomtestBO;
            }

            BO.Location boLocation = new BO.Location();
            using (LocationRepository sr = new LocationRepository(_context))
            {
                boLocation      = sr.Convert <BO.Location, Location>(room.Location);
                roomBO.location = boLocation;
            }
            BO.Schedule boSchedule = new BO.Schedule();
            using (ScheduleRepository cmp = new ScheduleRepository(_context))
            {
                boSchedule = cmp.Convert <BO.Schedule, Schedule>(room.Schedule);
                // cmp.Save(boSchedule);
                roomBO.schedule = boSchedule;
            }
            return((T)(object)roomBO);
        }
Ejemplo n.º 3
0
        public override object Get <T>(T entity)
        {
            List <BO.Schedule> lstSchedules = new List <BO.Schedule>();

            BO.Schedule scheduleBO = (BO.Schedule)(object) entity;

            if (scheduleBO != null)
            {
                if (scheduleBO.ID == 0)
                {
                    var acc_ = _context.Schedules.Include("ScheduleDetails").Where(p => (p.IsDeleted == false || p.IsDeleted == null)).ToList <Schedule>();
                    if (acc_ == null)
                    {
                        return(new BO.ErrorObject {
                            ErrorMessage = "No records found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                        });
                    }
                    foreach (Schedule item in acc_)
                    {
                        lstSchedules.Add(Convert <BO.Schedule, Schedule>(item));
                    }
                }
                else
                {
                    var acc_ = _context.Schedules.Include("ScheduleDetails").Where(p => (p.IsDeleted == false || p.IsDeleted == null) && p.ScheduleDetails.Any(x => x.ScheduleID == scheduleBO.ID)).ToList <Schedule>();
                    if (acc_ == null)
                    {
                        return(new BO.ErrorObject {
                            ErrorMessage = "No records found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                        });
                    }
                    foreach (Schedule item in acc_)
                    {
                        lstSchedules.Add(Convert <BO.Schedule, Schedule>(item));
                    }
                }
            }
            else
            {
                var acc_ = _context.Schedules.Include("ScheduleDetails").Where(p => (p.IsDeleted == false || p.IsDeleted == null)).ToList <Schedule>();
                if (acc_ == null)
                {
                    return(new BO.ErrorObject {
                        ErrorMessage = "No records found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                    });
                }
                foreach (Schedule item in acc_)
                {
                    lstSchedules.Add(Convert <BO.Schedule, Schedule>(item));
                }
            }

            return(lstSchedules);
        }
Ejemplo n.º 4
0
        public override T Convert <T, U>(U entity)
        {
            Schedule schedule = entity as Schedule;

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

            BO.Schedule scheduleBO = new BO.Schedule();
            scheduleBO.Name      = schedule.Name;
            scheduleBO.ID        = schedule.id;
            scheduleBO.CompanyId = schedule.CompanyId;
            scheduleBO.isDefault = schedule.IsDefault;

            if (schedule.IsDeleted.HasValue)
            {
                scheduleBO.IsDeleted = schedule.IsDeleted.Value;
            }
            if (schedule.UpdateByUserID.HasValue)
            {
                scheduleBO.UpdateByUserID = schedule.UpdateByUserID.Value;
            }

            BO.ScheduleDetail        scheduledetailBO    = null;
            List <BO.ScheduleDetail> lstscheduledetailBO = new List <BO.ScheduleDetail>();

            foreach (var scheduledetail in schedule.ScheduleDetails)
            {
                scheduledetailBO                = new BO.ScheduleDetail();
                scheduledetailBO.ID             = scheduledetail.id;
                scheduledetailBO.Name           = scheduledetail.Name;
                scheduledetailBO.dayofWeek      = scheduledetail.DayOfWeek;
                scheduledetailBO.slotStart      = scheduledetail.SlotStart;
                scheduledetailBO.slotEnd        = scheduledetail.SlotEnd;
                scheduledetailBO.slotDate       = scheduledetail.SlotDate;
                scheduledetailBO.scheduleStatus = (BO.GBEnums.ScheduleStatus)scheduledetail.Status;

                if (scheduledetail.IsDeleted.HasValue)
                {
                    scheduledetailBO.IsDeleted = scheduledetail.IsDeleted.Value;
                }
                if (scheduledetail.UpdateByUserID.HasValue)
                {
                    scheduledetailBO.UpdateByUserID = scheduledetail.UpdateByUserID.Value;
                }
                lstscheduledetailBO.Add(scheduledetailBO);
            }
            scheduleBO.ScheduleDetails = lstscheduledetailBO;

            return((T)(object)scheduleBO);
        }
Ejemplo n.º 5
0
        public override object Delete <T>(T entity)
        {
            BO.Schedule scheduleBO = entity as BO.Schedule;

            Schedule scheduleDB = new Schedule();

            scheduleDB.id = scheduleBO.ID;
            _dbSet.Remove(_context.Schedules.Single <Schedule>(p => p.id == scheduleBO.ID));
            _context.SaveChanges();

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

            return(scheduleDB);
        }
Ejemplo n.º 6
0
        //#region Get By Company Filter
        //public override object GetByCompanyId(int CompanyId)
        //{
        //    List<BO.Schedule> lstSchedules = new List<BO.Schedule>();

        //    var acc_ = _context.Schedules.Include("ScheduleDetails").Where(p => p.Locations.Where(p2 => (p2.IsDeleted.HasValue == false || (p2.IsDeleted.HasValue == true && p2.IsDeleted.Value == false)))
        //                                                                                   .Any(p3 => p3.CompanyID == CompanyId
        //                                                                                          && (p3.IsDeleted.HasValue == false || (p3.IsDeleted.HasValue == true && p3.IsDeleted.Value == false))) == true
        //                                                                    && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
        //                                                            .ToList<Schedule>();
        //    if (acc_ == null)
        //    {
        //        return new BO.ErrorObject { ErrorMessage = "No records found.", errorObject = "", ErrorLevel = ErrorLevel.Error };
        //    }
        //    foreach (Schedule item in acc_)
        //    {
        //        lstSchedules.Add(Convert<BO.Schedule, Schedule>(item));
        //    }

        //    return lstSchedules;
        //}
        //#endregion

        #region Get By Location Filter
        public override object GetByLocationId(int LocationId)
        {
            //var location = _context.Locations.Where(p => p.id == LocationId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
            //                                                      .Select(p => p.ScheduleID);
            //var acc = _context.Schedules.Include("ScheduleDetails").Where(p => location.Contains(p.id) && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
            //                                                       .FirstOrDefault<Schedule>();

            var acc = _context.Schedules.Include("ScheduleDetails")
                      .Where(p => p.Locations.Any(p2 => p2.id == LocationId &&
                                                  (p2.IsDeleted.HasValue == false || (p2.IsDeleted.HasValue == true && p2.IsDeleted.Value == false))) == true)
                      .FirstOrDefault();


            if (acc == null)
            {
                return(new BO.ErrorObject {
                    ErrorMessage = "No records found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                });
            }
            BO.Schedule acc_ = Convert <BO.Schedule, Schedule>(acc);
            return((object)acc_);
        }
Ejemplo n.º 7
0
        public override object Get(int id)
        {
            //Schedule if not found will return a empty list object, instead of message, as this was requested by UI Team
            BO.Schedule acc_ = Convert <BO.Schedule, Schedule>(_context.Schedules.Include("ScheduleDetails").Where(p => p.id == id && (p.IsDeleted == false || p.IsDeleted == null)).FirstOrDefault <Schedule>());
            if (acc_ == null)
            {
                return(new BO.ErrorObject {
                    ErrorMessage = "No record found for this schedule.", errorObject = "", ErrorLevel = ErrorLevel.Error
                });
            }
            return((object)acc_);

            //Schedule schedule = _context.Schedules.Include("ScheduleDetails").Where(p => p.id == id && (p.IsDeleted == false || p.IsDeleted == null)).FirstOrDefault<Schedule>();

            //BO.Schedule acc_ = new BO.Schedule();
            //if (schedule == null)
            //{
            //    return (object)acc_;
            //}

            //acc_ = Convert<BO.Schedule, Schedule>(schedule);
            //return (object)acc_;
        }
Ejemplo n.º 8
0
        public override T Convert <T, U>(U entity)
        {
            Location location = entity as Location;

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

            BO.Location locationBO = new BO.Location();

            locationBO.ID           = location.id;
            locationBO.Name         = location.Name;
            locationBO.IsDefault    = location.IsDefault;
            locationBO.LocationType = (BO.GBEnums.LocationType)location.LocationType;
            if (location.IsDeleted.HasValue)
            {
                locationBO.IsDeleted = location.IsDeleted.Value;
            }
            if (location.UpdateByUserID.HasValue)
            {
                locationBO.UpdateByUserID = location.UpdateByUserID.Value;
            }



            if (location.Company != null)
            {
                BO.Company boCompany = new BO.Company();
                boCompany.ID          = location.Company.id;
                boCompany.Name        = location.Company.Name;
                boCompany.TaxID       = location.Company.TaxID;
                boCompany.Status      = (BO.GBEnums.AccountStatus)location.Company.Status;
                boCompany.CompanyType = (BO.GBEnums.CompanyType)location.Company.CompanyType;
                if (location.Company.SubscriptionPlanType != null)
                {
                    boCompany.SubsCriptionType = (BO.GBEnums.SubsCriptionType)location.Company.SubscriptionPlanType;
                }
                else
                {
                    boCompany.SubsCriptionType = null;
                }

                locationBO.Company = boCompany;
            }

            if (location.AddressInfo != null)
            {
                BO.AddressInfo boAddress = new BO.AddressInfo();
                boAddress.Name     = location.AddressInfo.Name;
                boAddress.Address1 = location.AddressInfo.Address1;
                boAddress.Address2 = location.AddressInfo.Address2;
                boAddress.City     = location.AddressInfo.City;
                boAddress.State    = location.AddressInfo.State;
                boAddress.ZipCode  = location.AddressInfo.ZipCode;
                boAddress.Country  = location.AddressInfo.Country;
                //[STATECODE-CHANGE]
                //boAddress.StateCode = location.AddressInfo.StateCode;
                //[STATECODE-CHANGE]
                boAddress.CreateByUserID = location.AddressInfo.CreateByUserID;
                boAddress.ID             = location.AddressInfo.id;
                if (location.AddressInfo.IsDeleted.HasValue)
                {
                    boAddress.IsDeleted = location.AddressInfo.IsDeleted.Value;
                }
                if (location.AddressInfo.UpdateByUserID.HasValue)
                {
                    boAddress.UpdateByUserID = location.AddressInfo.UpdateByUserID.Value;
                }
                locationBO.AddressInfo = boAddress;
            }

            if (location.ContactInfo != null)
            {
                BO.ContactInfo boContactInfo = new BO.ContactInfo();
                boContactInfo.Name           = location.ContactInfo.Name;
                boContactInfo.CellPhone      = location.ContactInfo.CellPhone;
                boContactInfo.EmailAddress   = location.ContactInfo.EmailAddress;
                boContactInfo.HomePhone      = location.ContactInfo.HomePhone;
                boContactInfo.WorkPhone      = location.ContactInfo.WorkPhone;
                boContactInfo.FaxNo          = location.ContactInfo.FaxNo;
                boContactInfo.CreateByUserID = location.ContactInfo.CreateByUserID;
                boContactInfo.ID             = location.ContactInfo.id;
                if (location.ContactInfo.IsDeleted.HasValue)
                {
                    boContactInfo.IsDeleted = location.ContactInfo.IsDeleted.Value;
                }
                if (location.ContactInfo.UpdateByUserID.HasValue)
                {
                    boContactInfo.UpdateByUserID = location.ContactInfo.UpdateByUserID.Value;
                }
                locationBO.ContactInfo = boContactInfo;
            }
            BO.Schedule boSchedule = new BO.Schedule();
            using (ScheduleRepository cmp = new ScheduleRepository(_context))
            {
                boSchedule = cmp.Convert <BO.Schedule, Schedule>(location.Schedule);
                // cmp.Save(boSchedule);
                locationBO.Schedule = boSchedule;
            }
            return((T)(object)locationBO);
        }
        public override T Convert <T, U>(U entity)
        {
            DoctorLocationSchedule doctorlocationschedule = entity as DoctorLocationSchedule;

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

            BO.DoctorLocationSchedule doctorlocationscheduleBO = new BO.DoctorLocationSchedule();

            doctorlocationscheduleBO.ID = doctorlocationschedule.id;
            if (doctorlocationschedule.IsDeleted.HasValue)
            {
                doctorlocationscheduleBO.IsDeleted = doctorlocationschedule.IsDeleted.Value;
            }
            if (doctorlocationschedule.UpdateByUserID.HasValue)
            {
                doctorlocationscheduleBO.UpdateByUserID = doctorlocationschedule.UpdateByUserID.Value;
            }

            if (doctorlocationschedule.Doctor != null && (doctorlocationschedule.Doctor.IsDeleted.HasValue == false || (doctorlocationschedule.Doctor.IsDeleted.HasValue == true && doctorlocationschedule.Doctor.IsDeleted.Value == false)))
            {
                BO.Doctor boDoctor = new BO.Doctor();
                using (DoctorRepository cmp = new DoctorRepository(_context))
                {
                    boDoctor = cmp.ObjectConvert <BO.Doctor, Doctor>(doctorlocationschedule.Doctor);

                    if (boDoctor != null && doctorlocationschedule.Doctor != null && doctorlocationschedule.Doctor.User != null)
                    {
                        using (UserRepository userRep = new UserRepository(_context))
                        {
                            boDoctor.user = userRep.Convert <BO.User, User>(doctorlocationschedule.Doctor.User);
                        }
                    }

                    doctorlocationscheduleBO.doctor = boDoctor;
                }
            }

            if (doctorlocationschedule.Location != null && (doctorlocationschedule.Location.IsDeleted.HasValue == false || (doctorlocationschedule.Location.IsDeleted.HasValue == true && doctorlocationschedule.Location.IsDeleted.Value == false)))
            {
                BO.Location boLocation = new BO.Location();
                using (LocationRepository cmp = new LocationRepository(_context))
                {
                    boLocation = cmp.Convert <BO.Location, Location>(doctorlocationschedule.Location);
                    doctorlocationscheduleBO.location = boLocation;
                }
            }

            if (doctorlocationschedule.Schedule != null && (doctorlocationschedule.Schedule.IsDeleted.HasValue == false || (doctorlocationschedule.Schedule.IsDeleted.HasValue == true && doctorlocationschedule.Schedule.IsDeleted.Value == false)))
            {
                BO.Schedule boSchedule = new BO.Schedule();
                using (ScheduleRepository cmp = new ScheduleRepository(_context))
                {
                    boSchedule = cmp.Convert <BO.Schedule, Schedule>(doctorlocationschedule.Schedule);
                    doctorlocationscheduleBO.schedule = boSchedule;
                }
            }

            return((T)(object)doctorlocationscheduleBO);
        }
Ejemplo n.º 10
0
        public override object Save <T>(T entity)
        {
            BO.Schedule scheduleBO = (BO.Schedule)(object) entity;

            Schedule       scheduleDB       = new Schedule();
            ScheduleDetail scheduledetailDB = null;

            #region Schedule
            scheduleDB.id        = scheduleBO.ID;
            scheduleDB.Name      = scheduleBO.Name;
            scheduleDB.IsDefault = scheduleBO.isDefault;
            scheduleDB.IsDeleted = scheduleBO.IsDeleted.HasValue ? scheduleBO.IsDeleted : false;
            #endregion

            if (scheduleDB.id == 0)
            {
                if (_context.Schedules.Any(o => o.Name == scheduleBO.Name && (o.CompanyId == scheduleBO.CompanyId || o.IsDefault == true)))
                {
                    return(new BO.ErrorObject {
                        ErrorMessage = "Schedule already exists.", errorObject = "", ErrorLevel = ErrorLevel.Error
                    });
                }
            }

            #region Schedule Detail
            foreach (var scheduledetailBO in scheduleBO.ScheduleDetails)
            {
                scheduledetailDB           = new ScheduleDetail();
                scheduledetailDB.id        = scheduledetailBO.ID;
                scheduledetailDB.Name      = scheduledetailBO.Name;
                scheduledetailDB.DayOfWeek = scheduledetailBO.dayofWeek;
                scheduledetailDB.SlotStart = scheduledetailBO.slotStart;
                scheduledetailDB.SlotEnd   = scheduledetailBO.slotEnd;
                scheduledetailDB.SlotDate  = scheduledetailBO.slotDate;
                scheduledetailDB.Status    = System.Convert.ToByte(scheduledetailBO.scheduleStatus);
                scheduledetailDB.IsDeleted = scheduledetailBO.IsDeleted.HasValue ? scheduledetailBO.IsDeleted : false;
                scheduleDB.ScheduleDetails.Add(scheduledetailDB);
            }

            #endregion
            if (scheduleDB.id > 0)
            {
                //For Update Record

                //Find Schedule By ID
                Schedule schedule = _context.Schedules.Where(p => p.id == scheduleDB.id).FirstOrDefault <Schedule>();

                if (schedule != null && !schedule.IsDefault)
                {
                    _dbSetScheduleDetail.RemoveRange(_context.ScheduleDetails.Where(c => c.ScheduleID == scheduleBO.ID));
                    _context.SaveChanges();

                    #region Location
                    schedule.id             = scheduleBO.ID;
                    schedule.Name           = scheduleBO.Name == null ? schedule.Name : scheduleBO.Name;
                    schedule.IsDeleted      = scheduleBO.IsDeleted == null ? scheduleBO.IsDeleted : schedule.IsDeleted;
                    schedule.UpdateDate     = scheduleBO.UpdateDate;
                    schedule.UpdateByUserID = scheduleBO.UpdateByUserID;
                    #endregion
                    _context.Entry(schedule).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    return new BO.ErrorObject {
                               errorObject = "", ErrorMessage = "Invalid schedule details or default schdule.", ErrorLevel = ErrorLevel.Error
                    }
                };
                schedule.ScheduleDetails = scheduleDB.ScheduleDetails;

                if (scheduleBO.CompanyId.HasValue == false || (scheduleBO.CompanyId.HasValue == true && scheduleBO.CompanyId.Value <= 0))
                {
                    return(new BO.ErrorObject {
                        errorObject = "", ErrorMessage = "Invalid company id.", ErrorLevel = ErrorLevel.Error
                    });
                }
                else
                {
                    bool ExistsCompany = _context.Companies.Any(p => p.id == scheduleBO.CompanyId.Value && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)));
                    if (ExistsCompany == false)
                    {
                        return(new BO.ErrorObject {
                            errorObject = "", ErrorMessage = "Company id dosent exists.", ErrorLevel = ErrorLevel.Error
                        });
                    }
                    schedule.CompanyId = scheduleBO.CompanyId;
                }
            }
            else
            {
                scheduleDB.CreateDate     = scheduleBO.CreateDate;
                scheduleDB.CreateByUserID = scheduleBO.CreateByUserID;

                if (scheduleBO.CompanyId.HasValue == false || (scheduleBO.CompanyId.HasValue == true && scheduleBO.CompanyId.Value <= 0))
                {
                    return(new BO.ErrorObject {
                        errorObject = "", ErrorMessage = "Invalid company id.", ErrorLevel = ErrorLevel.Error
                    });
                }
                else
                {
                    bool ExistsCompany = _context.Companies.Any(p => p.id == scheduleBO.CompanyId.Value && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)));
                    if (ExistsCompany == false)
                    {
                        return(new BO.ErrorObject {
                            errorObject = "", ErrorMessage = "Company id dosent exists.", ErrorLevel = ErrorLevel.Error
                        });
                    }
                    scheduleDB.CompanyId = scheduleBO.CompanyId;
                }

                _dbSet.Add(scheduleDB);
            }
            _context.SaveChanges();

            var res = Convert <BO.Schedule, Schedule>(scheduleDB);
            return((object)res);
        }