Beispiel #1
0
        public ReportDataTemplateResponse InsertOrUpdateReportDataTemplate(ReportDataTemplateEntity reportDataTemplate)
        {
            var response = new ReportDataTemplateResponse();

            try
            {
                if (reportDataTemplate != null)
                {
                    if (!reportDataTemplate.Validate())
                    {
                        foreach (string error in reportDataTemplate.ValidationErrors)
                        {
                            response.Message += error + Environment.NewLine;
                        }
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }

                    if (reportDataTemplate.DataTemplateCode != null)
                    {
                        var index = ReportDataTemplateDao.ReportDataTemplate_InsertOrUpdate(reportDataTemplate);
                        if (index < 1)
                        {
                            response.Acknowledge = AcknowledgeType.Failure;
                            return(response);
                        }
                        response.Index = index;
                    }
                }
            }
            catch (Exception) { }

            return(response);
        }
 private object[] Take(ReportDataTemplateEntity reportDataTemplate)
 {
     return(new object[]
     {
         "@DataTemplateCode", reportDataTemplate.DataTemplateCode,
         "@Value", reportDataTemplate.Value,
         "@Description", reportDataTemplate.Description,
     });
 }
        public long ReportDataTemplate_InsertOrUpdate(ReportDataTemplateEntity reportDataTemplate)
        {
            const string sql = @"uspReportDataTemplate_InsertOrUpdate";
            var          reportDataTemplateByCode = GetReportDataTemplateByCode(reportDataTemplate.DataTemplateCode);

            if (reportDataTemplateByCode != null)
            {
                return(Db.Update(sql, true, Take(reportDataTemplate)) == "1" ? 1 : 0);
            }
            return(Db.Insert(sql, true, Take(reportDataTemplate)));
        }
Beispiel #4
0
 internal static ReportDataTemplateModel FromDataTransferObject(ReportDataTemplateEntity entity)
 {
     return(entity == null ? null : AutoMapper.Mapper.Map <ReportDataTemplateEntity, ReportDataTemplateModel>(entity));
 }