public async Task <IActionResult> PutCarVisit(Guid id, CarVisit carVisit) { if (id != carVisit.Id) { return(BadRequest()); } _context.Entry(carVisit).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarVisitExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <CarVisit> > LeaveCarVisit([FromBody] string carRegistryNumber) { CarVisit currentCar = _context.CarVisits.Where((m) => m.RegistryNumber == carRegistryNumber && m.EndTime == null).FirstOrDefault(); currentCar.EndTime = DateTime.Now; await _context.SaveChangesAsync(); return(CreatedAtAction("LeaveCarVisit", new { id = currentCar.Id }, currentCar)); }
public async Task <ActionResult <CarVisit> > AddCarVisit([FromBody] string carRegistryNumber) { CarVisit carVisit = new CarVisit { RegistryNumber = carRegistryNumber }; _context.CarVisits.Add(carVisit); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCarVisit", new { id = carVisit.Id }, carVisit)); }
/// <summary> /// Metoda edytuje wartości na bazie obiektu CarVisit czyli wizyty /// </summary> /// <param name="visit">Obiekt wizyty w warszatcie</param> public void Edit(CarVisit visit) { try { using (var connection = new SqlConnection(ConncetionString)) { connection.Open(); var affectedRows = connection.Execute(CarWorkShopQueries.UpdateVisist, new CarVisit { DateFrom = visit.DateFrom, DateTo = visit.DateTo, Service = visit.Service, Description = visit.Description, Price = visit.Price, IsDone = visit.IsDone, ID = visit.ID }); Console.WriteLine(affectedRows); } } catch (Exception e) { } }
/// <summary> /// /Metoda zaczytująca wartości pól i zapisująca je na bazie /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { CarVisit visit = new CarVisit { ID = VisitId, Description = tbDescription.Text, Price = Convert.ToInt32(tbPrize.Text), Service = tbService.Text, DateFrom = mtbDateFrom.Text, DateTo = mtbDateTo.Text, IsDone = checBoxDone.Checked }; var sr = new ServiceRepository(); sr.Edit(visit); if (RefreshGrid != null) { RefreshGrid(sender, e); } this.Close(); }