internal void UpdateFromSalesReceiptAsync(int id, SalesInvoiceUpdateModel model)
        {
            var data = DbSet.Single(m => m.Id == id);

            data.TotalPaid = model.TotalPaid;
            data.IsPaidOff = model.IsPaidOff;
            EntityExtension.FlagForUpdate(data, IdentityService.Username, "sales-service");
        }
        public async void Update_From_SalesReceipt_Success()
        {
            var dbContext             = DbContext(GetCurrentMethod());
            var serviceProvider       = GetServiceProviderMock(dbContext).Object;
            SalesInvoiceFacade facade = new SalesInvoiceFacade(serviceProvider, dbContext);

            var data = await DataUtil(facade, dbContext).GetTestData();

            var model = new SalesInvoiceUpdateModel()
            {
                IsPaidOff = false,
                TotalPaid = 1000,
            };


            var Response = await facade.UpdateFromSalesReceiptAsync((int)data.Id, model);

            Assert.NotEqual(Response, 0);
        }
        public async Task <int> UpdateFromSalesReceiptAsync(int id, SalesInvoiceUpdateModel model)

        {
            int Updated = 0;

            using (var transaction = DbContext.Database.BeginTransaction())
            {
                try
                {
                    salesInvoiceLogic.UpdateFromSalesReceiptAsync(id, model);
                    Updated = await DbContext.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw e;
                }
            }
            return(Updated);
        }
        public async Task <IActionResult> UpdateFromSalesReceiptAsync([FromRoute] int id, [FromBody] SalesInvoiceUpdateModel model)
        {
            try
            {
                ValidateUser();

                await Facade.UpdateFromSalesReceiptAsync(id, model);

                return(NoContent());
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, Common.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(Common.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }