public async Task <int> CreateFromUnitPaymentCorrection(CreditorAccountUnitPaymentCorrectionPostedViewModel viewModel) { var model = await DbContext.CreditorAccounts.FirstOrDefaultAsync(entity => entity.UnitReceiptNoteNo == viewModel.UnitReceiptNoteNo); var result = 0; if (model != null) { var correction = new CreditorAccountModel( model.SupplierName, model.SupplierCode, model.SupplierIsImport, model.DivisionId, model.DivisionCode, model.DivisionName, model.UnitId, model.UnitCode, model.UnitName, viewModel.UnitPaymentCorrectionId, viewModel.UnitPaymentCorrectionNo, viewModel.UnitPaymentCorrectionDPP, viewModel.UnitPaymentCorrectionPPN, viewModel.UnitPaymentCorrectionMutation, viewModel.UnitPaymentCorrectionDate, model.UnitReceiptNoteNo, model.Products, model.UnitReceiptNoteDate, model.UnitReceiptNoteDPP, model.UnitReceiptNotePPN, model.UnitReceiptMutation, model.BankExpenditureNoteId, model.BankExpenditureNoteNo, model.BankExpenditureNoteDate, model.BankExpenditureNoteDPP, model.BankExpenditureNotePPN, model.BankExpenditureNoteMutation, model.MemoNo, model.MemoDate, model.MemoDPP, model.MemoPPN, model.MemoMutation, model.PaymentDuration, model.InvoiceNo, model.FinalBalance, model.CurrencyCode, model.DPPCurrency, model.CurrencyRate ); EntityExtension.FlagForCreate(correction, IdentityService.Username, UserAgent); DbSet.Add(correction); result = await DbContext.SaveChangesAsync(); } return(result); }
public async Task <IActionResult> UnitPaymentCorrectionPost([FromBody] CreditorAccountUnitPaymentCorrectionPostedViewModel viewModel) { try { VerifyUser(); //ValidateService.Validate(viewModel); await Service.CreateFromUnitPaymentCorrection(viewModel); return(NoContent()); } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }