public DataSaveResult Save() { Acc_AccountCategory dbAccountCategory; try { NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString); var dbAccountCategorys = from u in newAppsCnn.Acc_AccountCategory where u.CategoryId == this.CategoryId select u; if (dbAccountCategorys.Count() > 0) { dbAccountCategory = dbAccountCategorys.First(); this.ToDbAccountCategory(dbAccountCategory); } else { dbAccountCategory = new Acc_AccountCategory(); this.ToDbAccountCategory(dbAccountCategory); newAppsCnn.Acc_AccountCategory.Add(dbAccountCategory); } newAppsCnn.SaveChanges(); Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_AccountCategory", this); this.FromDbAccountCategory(dbAccountCategory); return new DataSaveResult() { SaveStatus = true }; } catch (Exception ex) { return new DataSaveResult() { SaveStatus = false ,ErrorMessage=ex.Message}; } }
public void ToDbAccountCategory(Acc_AccountCategory _dbAccountCategory) { _dbAccountCategory.CategoryId = this.CategoryId; _dbAccountCategory.CategoryName_Ara = this.CategoryName_Ara; _dbAccountCategory.CategroyName_Eng = this.CategroyName_Eng; _dbAccountCategory.IsDisableCategory = this.IsDisableCategory; }
public void FromDbAccountCategory(Acc_AccountCategory _dbAccountCategory) { this.CategoryId = _dbAccountCategory.CategoryId; this.CategoryName_Ara = _dbAccountCategory.CategoryName_Ara; this.CategroyName_Eng = _dbAccountCategory.CategroyName_Eng; this.IsDisableCategory = _dbAccountCategory.IsDisableCategory; this.IsNew = false; }