Esempio n. 1
0
        public EditFormData GetEdit(int id, out Notification notification)
        {
            notification = new Notification()
            {
                Type = NotificationType.Success
            };
            EditFormData data = new EditFormData();

            data.Data = new CushionTestReportDTO();
            data.Data.CushionTestReportFileDTOs = new List <CushionTestReportFileDTO>();
            data.Data.CushionTestStandardDTOs   = new List <CushionTestStandardDTO>();
            data.SupportCushionTestStandards    = new List <SupportCushionTestStandardDTO>();

            //OVER VIEW
            data.DataOverView = new CushionTestReportOverViewDTO();
            data.DataOverView.CushionTestReportFileOverViewDTOs = new List <CushionTestReportFileOverViewDTO>();
            data.DataOverView.CushionTestStandardOverViewDTOs   = new List <CushionTestStandardOverViewDTO>();

            try
            {
                using (CushionTestingMngEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        CushionTestingMng_CushionTestReport_View     dbItem  = context.CushionTestingMng_CushionTestReport_View.FirstOrDefault(s => s.CushionTestReportID == id);
                        CushionTestingMng_CushionTestReport_OverView dbItems = context.CushionTestingMng_CushionTestReport_OverView.FirstOrDefault(s => s.CushionTestReportID == id);
                        if (dbItem == null)
                        {
                            notification = new Notification()
                            {
                                Type = NotificationType.Error, Message = "Can not find data."
                            };
                            return(data);
                        }
                        if (dbItems == null)
                        {
                            notification = new Notification()
                            {
                                Type = NotificationType.Error, Message = "Can not find data."
                            };
                            return(data);
                        }
                        data.Data         = converter.DB2DTO_GetCushionTestReport(dbItem);
                        data.DataOverView = converter.DB2DTO_GetOverViewCushionTestReport(dbItems);
                    }
                    data.SupportCushionTestStandards = converter.DB2DTO_GetSupportCushionTestStandard(context.SupportMng_CushionTestStandard_View.ToList());
                }
            }
            catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type = NotificationType.Error, Message = ex.Message
                };
                return(data);
            }
            return(data);
        }
Esempio n. 2
0
 public DTO.CushionTestReportDTO DB2DTO_GetCushionTestReport(CushionTestingMng_CushionTestReport_View dbItems)
 {
     return(AutoMapper.Mapper.Map <CushionTestingMng_CushionTestReport_View, DTO.CushionTestReportDTO>(dbItems));
 }