public Data.Model.Schedule Update(int id, ScheduleSecondUpdateRequest req) { var entity = _context.Schedules.Find(id); _context.Schedules.Attach(entity); _context.Schedules.Update(entity); if (req.updateTotalPrice) { entity.totalPrice = req.TotalPrice; } if (req.updateIsPaid) { entity.isPaid = true; } _context.SaveChanges(); return(_mapper.Map <Data.Model.Schedule>(entity)); }
private async void btnSetPayment_Click(object sender, EventArgs e) { var paymentModel = await _paymentService.Insert <Data.Model.Payments>(new PaymentInsertRequest() { PaymentDate = DateTime.Now, Amount = scheduleVM.totalPrice, PaymentTypeID = 1, ScheduleID = scheduleVM.ScheduleID }); if (paymentModel != null) { MessageBox.Show("Evidentirali ste uplatu klijenta.", "Operacija uspješno izvršena.", MessageBoxButtons.OK, MessageBoxIcon.Information); ScheduleSecondUpdateRequest req = new ScheduleSecondUpdateRequest() { updateIsPaid = true }; await _scheduleSecondService.Update <Data.Model.Schedule>(scheduleVM.ScheduleID, req); this.Close(); } }
public Data.Model.Schedule Update(int id, [FromBody] ScheduleSecondUpdateRequest req) { return(_service.Update(id, req)); }
private async void frmScheduleDetails_Load(object sender, EventArgs e) { scheduleVM = await _scheduleService.GetById <Data.ViewModel.ScheduleVM>(_scheduleID); txtScheduleDate.Text = scheduleVM.Date; txtClient.Text = scheduleVM.User + " | " + scheduleVM.UserCar; txtStatusSchedule.Text = scheduleVM.Status; txtIsPaidSchedule.Text = scheduleVM.isPaidString; btnDeleteSchedule.Visible = false; LabelTotalPrice.Visible = false; txtTotalPrice.Text = ""; btnShowPaymentDetails.Visible = false; if (scheduleVM.offerCreated) { btnSendOffer.Enabled = false; txtIsOfferSent.Visible = true; //cmbPartsSubCategories.Visible = false; btnAddToOfferList.Enabled = false; //txtSelectedCategory.Visible = false; //txtSubCategoryName.Visible = false; //txtQuantityNeeded.Visible = false; //txtNeededQuantity.Visible = false; txtNeededQuantity.ReadOnly = true; txtNeededQuantity.Enabled = false; } else { cmbPartsSubCategories.Visible = true; btnSendOffer.Visible = true; txtIsOfferSent.Visible = false; btnAddToOfferList.Visible = true; txtSelectedCategory.Visible = true; txtSubCategoryName.Visible = true; txtQuantityNeeded.Visible = true; txtNeededQuantity.Visible = true; } if (scheduleVM.ScheduleStatusID == 2) { btnFinishSchedule.Visible = false; btnDeleteSchedule.Visible = true; var ticketList = await _ticketService.Get <List <Data.Model.Ticket> >(new TicketSearchRequest() { ScheduleID = scheduleVM.ScheduleID }); if (ticketList.Count() > 0) { var ticketModel = ticketList.First(); if (ticketModel != null) { txtLabelCreateTicket.Text = "Već ste poslali online račun klijentu!"; txtLabelCreateTicket.BackColor = System.Drawing.Color.Green; btnCreateOnlineTicket.Enabled = false; } } if (scheduleVM.isPaid) { btnSetPaymentDetails.Enabled = false; btnShowPaymentDetails.Visible = true; } var listOffer = await _offerService.Get <List <Data.ViewModel.OffersVM> >(new OfferSearchRequest() { ScheduleID = scheduleVM.ScheduleID }); if (listOffer.Count() > 0) { OfferVM = listOffer.First(); } if (OfferVM != null) { if (OfferVM.partsSelected) { OfferItemsVM = await _offerItemsService.GetById <Data.ViewModel.OfferItemsVM>(OfferVM.OfferID); } } RequestVM = await _requestClientService.GetById <Data.ViewModel.RequestVM>(scheduleVM.RequestID); double UkupnaCijena = 0; foreach (var x in RequestVM.ListOfRequestedServices) { UkupnaCijena += x.ServicePrice; } if (OfferItemsVM != null) { if (OfferItemsVM.listOfParts.Count() > 0) { foreach (var i in OfferItemsVM.listOfParts) { UkupnaCijena += i.CarPartPrice * i.QuantityNeeded; } } } LabelTotalPrice.Visible = true; txtTotalPrice.Text = UkupnaCijena.ToString() + " KM"; ScheduleSecondUpdateRequest req = new ScheduleSecondUpdateRequest() { updateTotalPrice = true, TotalPrice = UkupnaCijena }; await _scheduleSecondService.Update <Data.Model.Schedule>(scheduleVM.ScheduleID, req); } scheduleVM.itemsforSelect.Insert(0, new Data.Model.CarPartSubCategory() { SubCategoryID = 0, SubCategoryName = "Odaberi podkategoriju dijela" }); cmbPartsSubCategories.ValueMember = "SubCategoryID"; cmbPartsSubCategories.DisplayMember = "SubCategoryName"; cmbPartsSubCategories.DataSource = scheduleVM.itemsforSelect; dgvSelectedSubCategories.AutoGenerateColumns = false; dgvSelectedSubCategories.DataSource = scheduleVM.selectedSubCategories; }