public async Task <IActionResult> AddSession(AddSessionDto newSession) { ServiceResponse <List <GetSessionDto> > response = await _sessionService.AddSession(newSession); if (response.Data == null) { return(BadRequest(response)); } return(Ok(response)); }
public IActionResult Add(AddSessionViewModel model) { var talk = talkService.GetTalk(model.TalkId); var venue = venueService.GetVenue(model.VenueId); var session = new Session { Talk = talk, Start = model.StartDate.AddHours(model.StartTime), Venue = venue, TalkType = talkService.GetTalkType(model.TalkTypeId), Status = SessionStatus.Open }; sessionService.AddSession(session); return(View("Index", new SessionListViewModel { SessionList = sessionService.GetSessions().ToList() })); }
public JsonResult JoinRoom(string deskCode, string auth) { var room = _roomService.GetRoomByDeskCode(deskCode); var user = _userService.GetUserByAuth(auth); if (user != null) { if (room != null) { var deskInRoom = room.Desks.Where(x => x.Code == deskCode).First(); if (!_sessionService.HasActiveSessionByRoom(room)) { _sessionService.AddSession(new Session() { Room = room, DateTimeCreated = DateTime.Now, DateTimeLastActive = DateTime.Now }); } var previousUser = deskInRoom.User; if (previousUser != null && previousUser.Session != null) { previousUser.Session = null; } user.Session = _sessionService.GetSessionByRoom(room); room.Desks.Where(x => x.User != null && x.User.Id == user.Id).ToList().ForEach(y => y.User = null); deskInRoom.User = user; _userService.Update(); return(Json(new { status = "OK" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "NO DESK" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { status = "WRONG AUTH" }, JsonRequestBehavior.AllowGet)); } }
public async Task <HttpResponseMessage> Login(UserViewModel user) { var userByLogin = await _sessionService.MatchPassword(user); if (userByLogin.Id != 0) { var sessionHash = await _sessionService.AddSession(userByLogin); var resp = new HttpResponseMessage(); var cookie = new CookieHeaderValue("session-id", sessionHash) { Expires = DateTimeOffset.Now.AddDays(1), Domain = Request.RequestUri.Host, Path = "/" }; resp.Headers.AddCookies(new[] { cookie }); return(resp); } throw new HttpResponseException(HttpStatusCode.Unauthorized); }
public ActionResult <AddSessionResponse> Add([FromBody] AddSessionRequest request) { request.CommanderID = User.GetUserId(); return(_sessionService.AddSession(request)); }