public DataSaveResult Save() { Acc_Accountype dbAccounttype; try { NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString); var dbAccounttypes = from u in newAppsCnn.Acc_Accountype where u.TypeID == this.TypeID select u; if (dbAccounttypes.Count() > 0) { dbAccounttype = dbAccounttypes.First(); this.ToDbAccounttype(dbAccounttype); } else { dbAccounttype = new Acc_Accountype(); this.ToDbAccounttype(dbAccounttype); newAppsCnn.Acc_Accountype.Add(dbAccounttype); } newAppsCnn.SaveChanges(); Audit.AddDataAudit(Audit.AuditActionTypes.AddNew, "Acc_Accountype", this); this.FromDbAccounttype(dbAccounttype); return new DataSaveResult() { SaveStatus = true }; } catch (Exception ex) { return new DataSaveResult() { SaveStatus = false ,ErrorMessage=ex.Message}; } }
public void ToDbAccounttype(Acc_Accountype _dbAccounttype) { _dbAccounttype.TypeID = this.TypeID; _dbAccounttype.TypeName_Ara = this.TypeName_Ara; _dbAccounttype.TypeName_Eng = this.TypeName_Eng; _dbAccounttype.IsDisable = this.IsDisable; }
public void FromDbAccounttype(Acc_Accountype _dbAccounttype) { this.TypeID = _dbAccounttype.TypeID; this.TypeName_Ara = _dbAccounttype.TypeName_Ara; this.TypeName_Eng = _dbAccounttype.TypeName_Eng; this.IsDisable = _dbAccounttype.IsDisable; this.IsNew = false; }