Example #1
0
        public override EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };

            //try to get data
            try
            {
                using (ComplianceMngEntities context = CreateContext())
                {
                    EditFormData data = new EditFormData();
                    data.ComplianceProcessDTO          = new ComplianceProcessDTO();
                    data.FactoryDTOs                   = converter.DB2DTO_Factory(context.ComplianceMng_Factory_View.ToList());
                    data.ClientDTOs                    = converter.DB2DTO_Client(context.ComplianceMng_Client_View.ToList());
                    data.ComplianceCertificateTypeDTOs = converter.DB2DTO_ComplianceCertificateType(context.ComplianceMng_ComplianceCertificateType_View.ToList());
                    data.AuditStatusDTOs               = converter.DB2DTO_AuditStatus(context.ComplianceMng_AuditStatus_View.ToList());
                    data.EmployeeDTOs                  = converter.DB2DTO_Employee(context.ComplianceMng_Employee_View.ToList());

                    if (id > 0)
                    {
                        ComplianceMng_Compliance_View dbItem = context.ComplianceMng_Compliance_View
                                                               .Include("ComplianceMng_ComplianceAttachedFile_View")
                                                               .Include("ComplianceMng_CompliancePIC_View")
                                                               .FirstOrDefault(o => o.ComplianceProcessID == id);

                        data.ComplianceProcessDTO = converter.DB2DTO_ComplianceProcessDTO(dbItem);
                    }

                    return(data);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(new EditFormData());
            }
        }
Example #2
0
 public ComplianceProcessDTO DB2DTO_ComplianceProcessDTO(ComplianceMng_Compliance_View dbItems)
 {
     return(AutoMapper.Mapper.Map <ComplianceMng_Compliance_View, ComplianceProcessDTO>(dbItems));
 }