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

            data.Data = new MaterialTestReportDTO();
            data.Data.MaterialTestReportFileDTOs = new List <MaterialTestReportFileDTO>();
            data.Data.MaterialTestStandardDTOs   = new List <MaterialTestStandardDTO>();
            data.SupportMaterialTestStandards    = new List <SupportMaterialTestStandardDTO>();

            //OVER VIEW
            data.DataOverView = new MaterialTestReportOverViewDTO();
            data.DataOverView.MaterialTestReportFileOverViewDTOs = new List <MaterialTestReportFileOverViewDTO>();
            data.DataOverView.MaterialTestStandardOverViewDTOs   = new List <MaterialTestStandardOverViewDTO>();

            try
            {
                using (MaterialTestingMngEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        MaterialTestingMng_MaterialTestReport_View     dbItem  = context.MaterialTestingMng_MaterialTestReport_View.FirstOrDefault(s => s.MaterialTestReportID == id);
                        MaterialTestingMng_MaterialTestReport_OverView dbItems = context.MaterialTestingMng_MaterialTestReport_OverView.FirstOrDefault(s => s.MaterialTestReportID == 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_GetMaterialTestReport(dbItem);
                        data.DataOverView = converter.DB2DTO_GetOverViewMaterialTestReport(dbItems);
                    }
                    data.SupportMaterialTestStandards = converter.DB2DTO_GetSupportMaterialTestStandard(context.SupportMng_MaterialTestStandard_View.ToList());
                }
            }
            catch (Exception ex)
            {
                notification = new Notification()
                {
                    Type = NotificationType.Error, Message = ex.Message
                };
                return(data);
            }
            return(data);
        }
Exemplo n.º 2
0
 public DTO.MaterialTestReportDTO DB2DTO_GetMaterialTestReport(MaterialTestingMng_MaterialTestReport_View dbItems)
 {
     return(AutoMapper.Mapper.Map <MaterialTestingMng_MaterialTestReport_View, DTO.MaterialTestReportDTO>(dbItems));
 }