public static Boolean CreateDirectDebitTLetteremplate(DirectDebitLetterTemplate directDebit) { Boolean flag = false; if (!(IsExistingDirectDebitTemplate(directDebit))) { using (TransactionScope scope = new TransactionScope()) { using (var context = new SycousCon()) { try { context.DirectDebitLetterTemplates.AddObject(directDebit); context.SaveChanges(); scope.Complete(); context.AcceptAllChanges(); flag = true; } catch (Exception ex) { context.Dispose(); throw; } } } } return flag; }
public bool CreateRecord(object templateobj) { Boolean flag = false; DirectDebitTemplateClass template = (DirectDebitTemplateClass)templateobj; try { DirectDebitLetterTemplate _template = new DirectDebitLetterTemplate(); if (template.ClientID != null) { _template.ClientID = Convert.ToInt64(template.ClientID); } if (template.SiteID != null) { _template.SiteID = Convert.ToInt64(template.SiteID); } if (template.SFTP) { _template.SFTP = true; } if (template.LetterBody != null) { _template.LetterBody = template.LetterBody; } if (template.LetterType != null) { _template.LetterType = template.LetterType; } _template.CreateBy = template.CreateBy; _template.CreateDate = DateTime.Now; if ((_template.ClientID != null) && (_template.SiteID != null)) { flag = DAL.DALDirectDebitTemplate.CreateDirectDebitTLetteremplate(_template); } } catch (Exception ex) { throw; } return flag; }
public static bool IsExistingDirectDebitTemplate(DirectDebitLetterTemplate directDebit) { using (var context = new SycousCon()) { try { DirectDebitLetterTemplate objDirectDebit = context.DirectDebitLetterTemplates.SingleOrDefault(p => p.ClientID == directDebit.ClientID && p.SiteID == directDebit.SiteID && p.IsDeleted == 0); if (objDirectDebit != null) { return true; } else { return false; } } catch (Exception ex) { context.Dispose(); throw; } } }
public static Boolean UpdateDirectDebitTemplate(DirectDebitLetterTemplate directDebit) { using (TransactionScope scope = new TransactionScope()) { Boolean bol = false; using (var context = new SycousCon()) { try { var Update = context.DirectDebitLetterTemplates.Where(c => c.ID == directDebit.ID); foreach (DirectDebitLetterTemplate p in Update) { if (directDebit.ClientID != null) { p.ClientID = directDebit.ClientID; } if (directDebit.SiteID != null) { p.SiteID = directDebit.SiteID; } if (directDebit.SFTP != null) { p.SFTP = directDebit.SFTP; } else { p.SFTP = null; } if (directDebit.LetterBody != null) { p.LetterBody = directDebit.LetterBody; } else { p.LetterBody = null; } if (directDebit.LetterType != null) { p.LetterType = directDebit.LetterType; } else { // p.LetterType = null; } if (directDebit.CreateDate != null) { p.CreateDate = directDebit.CreateDate; } else { p.CreateDate = null; } if (directDebit.CreateBy != null) { p.CreateBy = directDebit.CreateBy; } else { p.CreateBy = null; } p.ModifyBy = directDebit.ModifyBy; //p.ModifyDate = DateTime.Now; }// context.SaveChanges(); context.AcceptAllChanges(); scope.Complete(); context.Dispose(); bol = true; } catch (Exception ex) { context.Dispose(); throw; } }// using return bol; } //trans }
public static DirectDebitLetterTemplate EditDirectDebitLetterTemplate(Int64 ID) { DirectDebitLetterTemplate directDebit = new DirectDebitLetterTemplate(); using (var context = new SycousCon()) { try { directDebit = context.DirectDebitLetterTemplates.SingleOrDefault(s => s.ID == ID && s.IsDeleted == 0); } catch (Exception ex) { context.Dispose(); throw; } } return directDebit; }