asp.net mvc - Extension method is not working properly -
My app is having some issue. When I keep a debug and check those values update properly. But if it's a Without running debug values correctly.How to get rid of this issue.
This is my stable extension method. The method is called as the top calling down. Public InvoiceDetail Booking (My Parameters) {var bookingProcessModel = BookingProcessDetails (providerKey, ownerKey, serviceId, petKeys, selected date, selected times, selected extras services, selected resources, edit user type, discount, special Value, isProviderPickUp); BookingProcessModel.Invoice.CalculateTotal (); // Here's the method I'm calling Catalog.SaveChanges (); // invoiceDetailModel = GetInvoiceDetailModel (bookingProcessModel.AppointmentModel, bookingProcessModel.Invoice) to save data base; Return invoice mode; } After the above method, the data base saving value is incorrect. But when I put a debug on the above extension method and it's working properly, check it.What's the problem? Any help? Your extension method assigns a ... is returning a I do not think you need a Something like this: If you want to stay with the extension method, you will need to assign return value.
Public Fixed Decimal CalculateTotal (Invoice Invoice) {var subotto = Invoice. SubTotal; var total = sub-total; If (invoice.fix == tap ||! Invoice fee.a ()) mathematics returns. Round (total, 2); Foreign currency (fees charged in invoicing, where (f => F.Iscelled). Order By (F = & gt; F. Prednens)) {var value = 0m; If (fee.Percentage.HasValue) {If (fee total! = Null) value + = total sum total value; } If (fee.Fixed.HasValue) {value + = fee.Fixed.Value; } Total + = value; } Return Mathematics. Round (total, 2); }
decimal , but you can do anything Not assigned to ...
Booking processModel. Invoice.Collulatetal ();
decimal value, so what you are looking for is the right behavior.
extension method for this , then you just type
on
for CalculateTotal one in your invoice class The method may be the invoice you pass in.
var calculatedInvoice = Invoice.CalculateTotal (bookingProcessModel.Invoice);
CalculateTotal will return the new invoice with the values calculated.
Comments
Post a Comment