public async Task AddOrUpdate(RentalFormViewModel obj) { obj.UserId = "001122"; var moviesRental = new List <MovieRental>(); foreach (var item in obj.MovieRentals.Where(x => x.Rental == true)) { moviesRental.Add(new MovieRental() { MovieId = item.Id, RentalId = obj.Id }); } var itemAdd = new Rental() { Id = obj.Id, DateRental = DateTime.Now, UserId = obj.UserId, MovieRentals = moviesRental }; if (itemAdd.Id == 0) { itemAdd.DateRental = DateTime.Now; await _base_repository_rental.Add(itemAdd); } else { await _base_repository_rental.Update(itemAdd); } }
public async Task <ActionResult> Post([FromBody] EventUser item) { try { await _eventUserRepository.Add(item); return(Ok()); } catch (Exception ex) { _logger.LogError(ex, $"{LocalLog}[Post][Item: {JsonConvert.SerializeObject(item)}]"); throw ex; } }
public async Task <IActionResult> CreateOrUpdate(Genre model) { if (model.Id != 0) { await _base_repository.Update(model); } else { model.DateCreated = DateTime.Now; await _base_repository.Add(model); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(User model) { await _base_repository.Add(model); return(RedirectToAction("Index", "Rental")); }