public async Task <int> AddPartyAsync(ExpenseHeadModel model) { long id = model.ExpenseHeadId; using (var dataService = DataServiceFactory.CreateDataService()) { var expense = new ExpenseHead(); if (expense != null) { UpdateExpenseHeadFromModel(expense, model); expense.ExpenseHeadGuid = Guid.NewGuid(); await dataService.AddExpenseHeadAsync(expense); model.Merge(await GetExpenseHeadAsync(dataService, expense.ExpenseHeadId)); } return(0); } }
public async Task <int> UpdateExpenseHeadAsync(ExpenseHeadModel model) { long id = model.ExpenseHeadId; using (var dataService = DataServiceFactory.CreateDataService()) { var expense = id > 0 ? await dataService.GetExpenseHeadAsync(model.ExpenseHeadId) : new ExpenseHead(); if (expense != null) { UpdateExpenseHeadFromModel(expense, model); await dataService.UpdateExpenseHeadAsync(expense); model.Merge(await GetExpenseHeadAsync(dataService, expense.ExpenseHeadId)); } return(0); } }