public async Task <IActionResult> Create([FromBody] Reservation reservation) { if (ModelState.IsValid) { try { var reserv = new Reservation { Id = reservation.Id, Name = reservation.Name, RoomId = reservation.RoomId, UserId = reservation.UserId, TimePeriod = reservation.TimePeriod, Date = reservation.Date }; _context.Reservations.Add(reserv); await _context.SaveChangesAsync(); ReservasionsStore.Save(_context.Reservations.ToList()); _logger.LogInformation($"resevation save id: {reservation.Id}"); return(Ok(reservation)); } catch (Exception ex) { _logger.LogError("Error occurend creating reservation", ex); return(StatusCode(500)); } } return(BadRequest(ModelState.Values.SelectMany(v => v.Errors).ToList())); }
public async Task <MeetingRoomModel> AddAsync(MeetingRoomModel entity) { var mapped = _mapper.Map <MeetingRoom>(entity); await _context.MeetingRooms.AddAsync(mapped); await _context.SaveChangesAsync(); return(entity); }
public async Task <IActionResult> Create([Bind("Title,TeacherId,StartTime,EndTime,MeetingId")] Subject subject) { if (ModelState.IsValid) { _context.Add(subject); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(RedirectToAction("MeetingSubjects", new { id = subject.MeetingId })); }
public async Task <IActionResult> Create([Bind("Id,Name,Pic,Summary,Address,StartDate,EndDate,Current")] Meeting meeting) { if (ModelState.IsValid) { _context.Add(meeting); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(meeting)); }
public async Task <IActionResult> Create([Bind("Id,Name,Title,Photo")] Teacher teacher) { if (ModelState.IsValid) { _context.Add(teacher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teacher)); }