Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public SupportFormData GetSupportData(string formName, out Library.DTO.Notification notification)
        {
            SupportFormData data = new SupportFormData();

            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };

            data.MeetingLocationDTOs = new List <MeetingLocationDTO>();
            data.Users = new List <Support.DTO.User2>();
            data.Sales = new List <SaleDTO>();
            data.EmployeeDepartmentDTOs = new List <EmployeeDepartmentDTO>();
            data.TimeRange = new List <string>();
            data.AppointmentAttachedFileTypes = new List <Support.DTO.AppointmentAttachedFileType>();

            try
            {
                using (PurchasingCalendarMngEntities context = CreateContext())
                {
                    switch (formName)
                    {
                    case "calendar":
                        foreach (PurchasingCalendarMng_MeetingLocation_View location in context.PurchasingCalendarMng_MeetingLocation_View.ToList())
                        {
                            data.MeetingLocationDTOs.Add(new MeetingLocationDTO()
                            {
                                MeetingLocationID = location.MeetingLocationID.Value, MeetingLocationNM = location.MeetingLocationNM, IsSelected = false
                            });
                        }
                        break;

                    case "editEvent":
                        data.Users = supportFactory.GetUsers2();
                        data.EmployeeDepartmentDTOs = converter.DB2DTO_EmployeeDepartment(context.PurchasingCalendarMng_Employee_View.ToList());
                        data.TimeRange = supportFactory.GetTimeRange();
                        data.AppointmentAttachedFileTypes = supportFactory.GetAppointmentAttachedFileType();
                        data.Sales = converter.DB2DTO_SaleList(context.PurchasingCalendarMng_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);
        }