public HttpResponseMessage AddSalesDetails([FromBody] SalesDetailsViewModel model) { try { salesdetailsRepository.AddSalesDetails(model); return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = model, message = "The record Created Successfully" })); //return Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "The was an error creating this record" }); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = $"there was an error creating this record {e.Message}" })); } }
public HttpResponseMessage UpdateSalesDetails([FromBody] SalesDetailsViewModel model) { try { var data = salesdetailsRepository.UpdateSalesDetails(model); if (data) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, Result = model, Message = "The record Updated Successfully" })); } return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = " There was an Error updating the record" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = $"There was an Error updating the record { ex.Message }" })); } }
public void AddSalesDetails(SalesDetailsViewModel entity) { var data = new tbl_SalesDetails { SalesDetailsId = entity.salesDetailsId, SalesTypeId = entity.salesTypeId, ProductId = entity.productId, StockId = entity.stockId, CustomerId = entity.customerId, Quantity = entity.quantity, SalesPrice = entity.salesPrice, AmountRecieved = entity.amountRecieved, SuppliedBy = entity.suppliedBy, SalesDate = entity.salesDate, PaymentId = entity.paymentId, BatchNo = reference.ConfirmReferenceNo((int)ReferenceTypesEnum.Invoice, 1), BranchId = entity.branchId }; context.tbl_SalesDetails.Add(data); //context.SaveChanges(); var pay = new PaymentViewModel { batchNo = data.BatchNo, recievedAmount = data.AmountRecieved, actualAmount = data.tbl_Payment.ActualAmount, paymentDate = data.SalesDate, paymentModeId = data.tbl_Payment.PaymentModeId, paymentMode = data.tbl_Payment.tbl_PaymentMode.PaymentMode, transactionStatus = data.tbl_Payment.tbl_TransactionStatus.TransactionStatus, transactionStatusId = data.tbl_Payment.TransactionStatusId, createdBy = data.tbl_Payment.CreatedBy, createdOn = data.tbl_Payment.CreatedOn, }; payment.AddPayments(pay); //return entity; }
public bool UpdateSalesDetails(SalesDetailsViewModel entity) { var data = (from d in context.tbl_SalesDetails where d.SalesDetailsId == entity.salesDetailsId select d).SingleOrDefault(); if (data != null) { data.SalesDetailsId = entity.salesDetailsId; data.SalesTypeId = entity.salesTypeId; data.ProductId = entity.productId; data.StockId = entity.stockId; data.CustomerId = entity.customerId; data.Quantity = entity.quantity; data.SalesPrice = entity.salesPrice; data.AmountRecieved = entity.amountRecieved; data.SuppliedBy = entity.suppliedBy; data.SalesDate = DateTime.Now; data.PaymentId = entity.paymentId; data.BatchNo = entity.batchNo; data.BranchId = entity.branchId; } return(context.SaveChanges() > 0); }