public async Task <IActionResult> PutCustomerIdentification(int id, CustomerIdentification customerIdentification) { if (id != customerIdentification.CustomerUniqueId) { return(BadRequest()); } _context.Entry(customerIdentification).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerIdentificationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPersonalTrainers(int id, PersonalTrainers personalTrainers) { if (id != personalTrainers.Id) { return(BadRequest()); } _context.Entry(personalTrainers).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonalTrainersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProductTable(int id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductTableExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCourse(int id, Course course) { if (id != course.CourseId) { return(BadRequest()); } _context.Entry(course).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAdminDetails(int id, AdminDetails adminDetails) { if (id != adminDetails.Id) { return(BadRequest()); } _context.Entry(adminDetails).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static async Task FillUp_CreateAsync(this MasterContext context, FillUpEntity fillUp) { var fillUpModel = new FillUpModel(); fillUpModel.LitresValue = fillUp.Litres; fillUpModel.LiterCost = fillUp.LiterCost; await context.FillUps.AddAsync(fillUpModel); await context.SaveChangesAsync(); var @event = new EventOccuredModel(); @event.Expense = fillUp.Expense; @event.Title = fillUp.Name; @event.Date = fillUp.OccuredDate; @event.Mileage = fillUp.Mileage; @event.EntityId = fillUpModel.Id; @event.Type = Data.Master.Model.EventType.FillUp; @event.Vehicle_VehicleId = fillUp.Vehicle.Id; await context.EventsOccured.AddAsync(@event); await context.SaveChangesAsync(); }
public async Task <IActionResult> UpdateGym([FromRoute] int id, [FromBody] UpdateGym input) { var result = await _context.Gym.FindAsync(id); if (result == null) { return(NotFound()); } try { var Update = new Gym() { Id = input.Id, Latitude = input.Latitude, Longitude = input.Longitude, Name = input.Name, Adress = input.Adress, Contact = input.Contact, Email = input.Email, Facebook = input.Facebook }; _context.Update(Update); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!GymIdExists(id)) { return(NotFound()); } return(Ok("Sucesso")); }
public async Task <IActionResult> Create([Bind("IdStudy,Name")] Studies studies) { if (ModelState.IsValid) { _context.Add(studies); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(studies)); }
public async Task <IActionResult> Create([Bind("Semester,IdStudy,StartDate,IdEnrollment")] Enrollment enrollment) { if (ModelState.IsValid) { _context.Add(enrollment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdStudy"] = new SelectList(_context.Studies, "IdStudy", "Name", enrollment.IdStudy); return(View(enrollment)); }
public async Task <IActionResult> Create([Bind("IndexNumber,FirstName,LastName,BirthDate,IdEnrollment")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdEnrollment"] = new SelectList(_context.Enrollment, "IdEnrollment", "IdEnrollment", student.IdEnrollment); return(View(student)); }