public async Task <UpsertBaseSalaryPackageResponse> UpsertBaseSalaryPackageAsync(UpsertBaseSalaryPackageRequest request) { return(await Task.Run(() => { UpsertBaseSalaryPackageResponse _response = new UpsertBaseSalaryPackageResponse(); using (AsyncAutomateAccountingEntities _dbContext = new AsyncAutomateAccountingEntities()) { if (request.BaseObject != null) { try { SalaryPackage _SalaryPackage = request.BaseObject.ToSalaryPackage(); UpsertEntity <SalaryPackage>(request.BaseObject.Id, ref _SalaryPackage, _dbContext); _response.BaseObject = _SalaryPackage.ToBaseSalaryPackage(); } 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 BaseSalaryPackageModel ToBaseSalaryPackage(this SalaryPackage salaryPackage) { BaseSalaryPackageModel _result = new BaseSalaryPackageModel(); _result.SalaryPackageName = salaryPackage.SalaryPackageName; _result.IsActive = salaryPackage.IsActive; _result.Narration = salaryPackage.Narration; _result.TotalAmount = salaryPackage.TotalAmount; _result.CreatedDate = salaryPackage.CreatedDate; _result.ModifiedDate = salaryPackage.ModifiedDate; return(_result); }
public SalaryPackage PackageSave(SalaryPackage cus) { //cus.Active = true; cus.CreateDate = DateTime.Now; cus.CreateBy = CurrentSession.GetCurrentSession().UserName; foreach (var item in cus.SalaryPackageDetails) { item.SalaryPackageId = cus.Id; } _salaryPackageservice.Save(cus); return(cus); }
public static SalaryPackage ToSalaryPackage(this BaseSalaryPackageModel salaryPackage) { SalaryPackage _result = new SalaryPackage(); if (salaryPackage.Id.HasValue) { _result.Id = salaryPackage.Id.GetValueOrDefault(); } _result.SalaryPackageName = salaryPackage.SalaryPackageName; _result.IsActive = salaryPackage.IsActive; _result.Narration = salaryPackage.Narration; _result.TotalAmount = salaryPackage.TotalAmount; _result.CreatedDate = salaryPackage.CreatedDate; _result.ModifiedDate = salaryPackage.ModifiedDate; return(_result); }