public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,ServiceType,PetId,StartDate,CheckoutDate,ServiceNote,CheckinTime,CheckoutTime")] ServicePet servicePet) { if (id != servicePet.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(servicePet); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServicePetExists(servicePet.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(MainCalendar))); } return(View(servicePet)); }
public IActionResult UpdatePetService([FromBody] ServicePet servicePet) { servicePet.UserId = _userManager.GetUserAsync(HttpContext.User).Result.Id; _context.Update(servicePet); _context.SaveChanges(); return(Json(servicePet)); }
public IActionResult CheckOutPet(ServicePet servicePet) { servicePet.CheckoutTime = DateTime.Now; _context.Update(servicePet); _context.SaveChanges(); Json(servicePet); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> CreatePet([FromBody] ServicePet servicePet) { var user = await _userManager.GetUserAsync(HttpContext.User); servicePet.UserId = user.Id; await _context.AddAsync(servicePet); await _context.SaveChangesAsync(); return(Json(servicePet)); }