예제 #1
0
        public DTO.SupportData GetSupportData(string formName, out Library.DTO.Notification notification)
        {
            DTO.SupportData data = new DTO.SupportData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            data.Factories                       = new List <Support.DTO.Factory>();
            data.MeetingLocations                = new List <DTO.MeetingLocation>();
            data.Users                           = new List <Support.DTO.User2>();
            data.Sales                           = new List <DTO.Sale>();
            data.employeeDepartmentDTOs          = new List <Support.DTO.EmployeeDepartmentDTO>();
            data.TimeRange                       = new List <string>();
            data.SCMAppointmentAttachedFileTypes = new List <Support.DTO.AppointmentAttachedFileType>();

            try
            {
                switch (formName)
                {
                case "calendar":
                    foreach (Support.DTO.MeetingLocation location in supportFactory.GetMeetingLocation())
                    {
                        if (location.MeetingLocationID == 1 || location.MeetingLocationID == 4)     //request Mr Luc AVT VIETNAM SHOWROOM AND AT FACTORY
                        {
                            data.MeetingLocations.Add(new DTO.MeetingLocation()
                            {
                                MeetingLocationID = location.MeetingLocationID, MeetingLocationNM = location.MeetingLocationNM, IsSelected = false
                            });
                        }
                    }
                    data.Factories = supportFactory.GetFactory();
                    break;

                case "editEvent":
                    data.Users = supportFactory.GetUsers2();
                    data.employeeDepartmentDTOs = supportFactory.GetDepartmentDTOs();
                    data.TimeRange = supportFactory.GetTimeRange();
                    data.SCMAppointmentAttachedFileTypes = supportFactory.GetAppointmentAttachedFileType();
                    using (SCMAgendaMngEntities context = CreateContext())
                    {
                        data.Sales = converter.DB2DTO_SaleList(context.SupportMng_Sale_View.Where(o => o.CompanyID.Value != 3).ToList());     // company different than AVT
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
            }
            return(data);
        }