public async Task <UpsertBaseBudgetMasterResponse> UpsertBaseBudgetMasterAsync(UpsertBaseBudgetMasterRequest request) { return(await Task.Run(() => { UpsertBaseBudgetMasterResponse _response = new UpsertBaseBudgetMasterResponse(); using (AsyncAutomateAccountingEntities _dbContext = new AsyncAutomateAccountingEntities()) { if (request.BaseObject != null) { try { BudgetMaster _BudgetMaster = request.BaseObject.ToBudgetMaster(); UpsertEntity <BudgetMaster>(request.BaseObject.Id, ref _BudgetMaster, _dbContext); _response.BaseObject = _BudgetMaster.ToBaseBudgetMaster(); } catch (Exception ex) { AssignStatusData(_response, false, string.Format("Some error occurred during DB interaction. Message is something like : \n{0}", ex.Message)); } } else { AssignStatusData(_response, false, "No entity data recieved to insert/update."); } } return _response; })); }
public static BaseBudgetMasterModel ToBaseBudgetMaster(this BudgetMaster budgetMaster) { BaseBudgetMasterModel _result = new BaseBudgetMasterModel(); _result.BudgetName = budgetMaster.BudgetName; _result.Type = budgetMaster.Type; _result.FromDate = budgetMaster.FromDate; _result.ToDate = budgetMaster.ToDate; _result.TotalDr = budgetMaster.TotalDr; _result.TotalCr = budgetMaster.TotalCr; _result.Narration = budgetMaster.Narration; _result.CreatedDate = budgetMaster.CreatedDate; _result.ModifiedDate = budgetMaster.ModifiedDate; return(_result); }
public static BudgetMaster ToBudgetMaster(this BaseBudgetMasterModel budgetMaster) { BudgetMaster _result = new BudgetMaster(); if (budgetMaster.Id.HasValue) { _result.Id = budgetMaster.Id.GetValueOrDefault(); } _result.BudgetName = budgetMaster.BudgetName; _result.Type = budgetMaster.Type; _result.FromDate = budgetMaster.FromDate; _result.ToDate = budgetMaster.ToDate; _result.TotalDr = budgetMaster.TotalDr; _result.TotalCr = budgetMaster.TotalCr; _result.Narration = budgetMaster.Narration; _result.CreatedDate = budgetMaster.CreatedDate; _result.ModifiedDate = budgetMaster.ModifiedDate; return(_result); }