public object Post(CreateSession message) { using (var db = _connectionFactory.Open()) { var session = new Session { JournalId = message.JournalId, Name = message.Name, Description = message.Description, CreatedAt = DateTime.Now }; try { long sessionId = db.Insert(session, true); return(new GeneralizedResponse { Message = "New Session Created! Id: " + sessionId }); } catch (Exception) { throw; } } }
private void CreateSession(CreateSession createSession) { // IActorRef sessionActor = Context.ActorOf(Context.DI().Props<SessionActor>(), $"session-{ createSession.SessionId }"); IActorRef sessionActor = Context.ActorOf(Props.Create <SessionActor>(), $"session-{ createSession.SessionId }"); sessionActor.Forward(createSession); }
public CreateSessionTest() { _readSessionRepository = A.Fake <IReadSessionRepository>(); _writeSessionRepository = A.Fake <IWriteSessionRepository>(); _command = new CreateSession(_readSessionRepository, _writeSessionRepository); }
//<------------------------------------------------------------------------------------------------------> //<------------------------------------------------------------------------------------------------------> private async Task <OperationResult <int> > Post(CreateSession item) { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { if (!item.ParameterValid()) { return new OperationResult <int>() { Success = false, Message = Messages.PARAMETERS_NOT_NULL } } ; var EventRes = await eventService.GetByIdAsync(item.eventId); if (!EventRes.Success) { return new OperationResult <int>() { Success = false, Message = EventRes.Message } } ; if (!EventRes.Result.community.admins.Any(elem => elem.id == item.userId)) { return new OperationResult <int>() { Success = false, Message = Messages.USER_NO_PERMISSION } } ; if (item.endDate.CompareTo(item.initialDate) <= 0) { return new OperationResult <int>() { Success = false, Message = Messages.END_DATE_NOT_VALID } } ; try { var id = await sessionRepo.PostAsync(item); scope.Complete(); return(new OperationResult <int>() { Success = true, Message = Messages.SESSION_CREATED, Result = id }); } catch (Exception ex) { return(new OperationResult <int>() { Success = false, Message = ex.Message }); } } }
/// <summary> /// Create session for getty images api /// </summary> /// <returns>CreateSessionResult</returns> private static CreateSessionResult CreateSession() { var session = new CreateSession(); var createSessionTokenResponse = session.GetCreateSessionResponse(); return(createSessionTokenResponse != null ? createSessionTokenResponse.CreateSessionResult : null); }
public SeminarSession(CreateSession cmd) { Id = cmd.Id; SeminarId = cmd.SeminarId; Attendees = new List <SessionAttendee>(); Status = SessionStatus.NotStarted; StartTime = null; EndTime = null; }
// GET: Session/Create public ActionResult Create() { CreateSession session = new CreateSession() { Films = _context.Films, Halls = _context.Halls }; return(View(session)); }
// GET: Session/Create public ActionResult Create() { CreateSession session = new CreateSession() { Films = _dao.Films.GetAll(), Halls = _dao.Halls.GetAll() }; return(View(session)); }
public async Task <Session <TSession, TUser> > CreateAsync <TSession, TUser>(CreateSession <TSession> session = null, string[] expand = null) { var additionalParams = new Dictionary <string, string>(); if (expand != null) { additionalParams.Add(nameof(expand), string.Join(",", expand)); } return(await HttpConnection.PostAsync <Session <TSession, TUser> >($"/sessions", session ?? new CreateSession <TSession>(), additionalParams)); }
private void CreateSession(CreateSession createSession) { logger.Info("Create session (Session Id: {0}, User Id: {1})", createSession.SessionId, createSession.UserId); // Console.WriteLine("Create session (Session Id: {0}, User Id: {1})", createSession.SessionId, createSession.UserId); sessionId = createSession.SessionId; userId = createSession.UserId; var sessionCreated = new SessionCreated(createSession.SessionId, Self); Sender.Tell(sessionCreated); }
private async Task <OperationResult <int> > Put(CreateSession item) { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var session = await sessionRepo.GetByIdAsync(item.id); if (session == null) { return new OperationResult <int>() { Success = false, Message = Messages.SESSION_NOT_EXIST } } ; if ([email protected](elem => elem.id == item.userId)) { return new OperationResult <int>() { Success = false, Message = Messages.USER_NO_PERMISSION } } ; try { session.title = item.title == null ? session.title : item.title; session.description = item.description == null ? session.description : item.description; session.speakerName = item.speakerName == null ? session.speakerName : item.speakerName; session.lastName = item.lastName == null ? session.lastName : item.lastName; session.linkOfSpeaker = item.linkOfSpeaker == null ? session.linkOfSpeaker : item.linkOfSpeaker; session.initialDate = item.initialDate == default(DateTime) ? session.initialDate : item.initialDate; session.endDate = item.endDate == default(DateTime) ? session.endDate : item.endDate; var id = await sessionRepo.PutAsync(session); scope.Complete(); return(new OperationResult <int>() { Success = true, Message = Messages.SESSION_UPDATED, Result = id }); } catch (Exception ex) { return(new OperationResult <int>() { Success = false, Message = ex.Message }); } } }
public async Task <CreateSessionResponse> CreateSession(string sessionName) { var createSessionData = new CreateSession() { Name = sessionName, Notification = true, Restricted = false, SessionEndDate = DateTime.Now.AddDays(30), DefaultPermissions = new List <DefaultSessionPermissions>() { new DefaultSessionPermissions() { Type = "SaveCopy", Allow = "Allow" }, new DefaultSessionPermissions() { Type = "PrintCopy", Allow = "Allow" }, new DefaultSessionPermissions() { Type = "Markup", Allow = "Allow" }, new DefaultSessionPermissions() { Type = "MarkupAlert", Allow = "Allow" }, new DefaultSessionPermissions() { Type = "AddDocuments", Allow = "Allow" } } }; var json = JsonConvert.SerializeObject(createSessionData); var client = new HttpAuthClient(); var sessionUrl = "https://studioapi.bluebeam.com/publicapi/v1/sessions"; var response = await client.Post(sessionUrl, json, User, _userManager); var createSessionResponse = JsonConvert.DeserializeObject <CreateSessionResponse>(response); return(createSessionResponse); }
public async Task <LoginResponse <TUser, TSession> > LoginAsync <TUser, TSession>(string login, string password, CreateSession <TSession> session = null, string[] expand = null) { var additionalParams = new Dictionary <string, string>(); if (expand != null) { additionalParams.Add(nameof(expand), string.Join(",", expand)); } if (session == null) { session = new CreateSession <TSession>(); } return(await HttpConnection.PostAsync <LoginResponse <TUser, TSession> >("/users/login", new { login, password, session }, additionalParams)); }
public HttpResponseMessage Post(CreateSession model) { if(!ModelState.IsValid) { return Request.CreateErrorResponse( HttpStatusCode.BadRequest,ModelState); } var success = signIn( model.Email.ToLowerInvariant(), model.Password, model.RememberMe.GetValueOrDefault()); return Request.CreateResponse(success ? HttpStatusCode.NoContent : HttpStatusCode.BadRequest); }
public HttpResponseMessage Post(CreateSession model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, ModelState)); } var success = signIn( model.Email.ToLowerInvariant(), model.Password, model.RememberMe.GetValueOrDefault()); return(Request.CreateResponse(success ? HttpStatusCode.NoContent : HttpStatusCode.BadRequest)); }
public Task <int> PostAsync(CreateSession item) { return(Task.Factory.StartNew(() => { var result = new session() { description = item.description, eventId = item.eventId, initialDate = item.initialDate, endDate = item.endDate, speakerName = item.speakerName, linkOfSpeaker = item.linkOfSpeaker, lastName = item.lastName, title = item.title }; context.session.Add(result); try { context.SaveChanges(); return result.id; } /*catch (Exception e) * { * * throw new ArgumentException(e.Message); * }*/ catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } })); }
private async Task <OperationResult <int> > Delete(CreateSession item) { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var session = await sessionRepo.GetByIdAsync(item.id); if (session == null) { return new OperationResult <int>() { Success = false, Message = Messages.SESSION_NOT_EXIST } } ; if ([email protected](elem => elem.id == item.userId)) { return new OperationResult <int>() { Success = false, Message = Messages.USER_NO_PERMISSION } } ; try { var id = await sessionRepo.DeleteAsync(session); scope.Complete(); return(new OperationResult <int>() { Success = true, Message = Messages.SESSION_DELETED_SUCCESS, Result = id }); } catch (Exception ex) { return(new OperationResult <int>() { Success = false, Message = ex.InnerException.Message }); } } } } }
// PUT: api/Session/5 public string Put(int id, [FromBody] CreateSession value) { SqlCommand cmd = new SqlCommand(); conn.Connectdb("update Session set Id_user=@Id_user, Date_session=@Date_session, Duration_session=@Duration_session where Id_session='" + id + "'", cmd); cmd.Parameters.AddWithValue("@Id_user", value.Id_user); cmd.Parameters.AddWithValue("@Date_session", value.Date_session); cmd.Parameters.AddWithValue("@Duration_session", value.Duration_session); int result = cmd.ExecuteNonQuery(); if (result > 0) { return("mise à jour réussie"); } else { return("echec mise à jour"); } }
public void Session(DataCover128kb data) { CreateSession si = Protocol.BufferToObject <CreateSession>(data.Data); RemoteDevice rd = ClientsControl.GetDevices().FirstOrDefault(x => x.Id.Value == si.RemDevId); if (rd != null) { string text = $"Запрос создания сессии id{Id.Value}:{Name} id{rd.Id.Value}:{rd.Name}"; LogWriter.SendLog(text); ClientsControl.SendGlobalChat(text); byte[] ip = new byte[4]; int port = si.CustomPort; string[] ipstrar = null; if (port > -1) { ipstrar = Program.GLOBALIP.Split('.'); } else { IPEndPoint ipep = (IPEndPoint)Client.RemoteEndPoint; ipstrar = ipep.Address.ToString().Split('.'); port = ipep.Port; } for (int i = 0; i < ip.Length; i += 1) { ip[i] = byte.Parse(ipstrar[i]); } byte[] pass = Guid.NewGuid().ToByteArray(); rd.Write(new DataCover128kb(new ConnectedInfo(ip, port, pass).Pack(), DataType.createSessionIpPort).Pack()); Write(new DataCover128kb(new ConnectedInfo(((IPEndPoint)rd.Client.RemoteEndPoint).Address.GetAddressBytes(), ((IPEndPoint)rd.Client.RemoteEndPoint).Port, pass).Pack(), DataType.createSessionIpPort).Pack()); } else { string text = $"В запросе создания сессии для {Id.Value}:{Name} отказано, удаленное устройство id:{si.RemDevId} не подключено"; LogWriter.SendLog(text); ClientsControl.SendGlobalChat(text); } }
// POST: api/Session public string Post([FromBody] CreateSession value) { SqlCommand cmd = new SqlCommand(); conn.Connectdb("insert into Session(Id_session, Id_user, Date_session, Duration_session)values(@Id_session, @Id_user, @Date_session, @Duration_session)", cmd); cmd.Parameters.AddWithValue("@Id_session", value.Id_session); //auto-incrementé cmd.Parameters.AddWithValue("@Id_user", value.Id_user); cmd.Parameters.AddWithValue("@Date_session", value.Date_session); cmd.Parameters.AddWithValue("@Duration_session", value.Duration_session); conn.Con.Open(); int result = cmd.ExecuteNonQuery(); if (result > 0) { return("insertion réussie"); } else { return("echec insertion"); } }
public async Task CreateAsync(CreateSession cmd) { cmd.Validate(); if (await _sessionsDao.ExistsByIdAsync(cmd.Id)) { throw new ObjectAlreadyExitsException(cmd.Id, typeof(SeminarSession)); } if (await _sessionsDao.ExistsByWhereAsync($"SeminarId = '{cmd.SeminarId}' AND Status != '{SessionStatus.Finished}'")) { throw new DomainException($"Can't create a seminar: {cmd.SeminarId} session until all sessions have finished"); } if (await _seminarDao.ExistsAsync(cmd.Id)) { throw new ObjectNotFoundException(cmd.SeminarId, typeof(Seminar)); } await _sessionsDao.AddAsync(new SeminarSession(cmd)); }
public async Task<HttpResponseMessage> Post(CreateSession model) { if (model == null) { throw new ArgumentNullException("model"); } if (!ModelState.IsValid) { return Request.CreateErrorResponse( HttpStatusCode.BadRequest, ModelState); } var success = await membershipService.InternalSignIn( model.Email.ToLower(CultureInfo.CurrentCulture), model.Password, model.RememberMe.GetValueOrDefault()); return Request.CreateResponse(success ? HttpStatusCode.NoContent : HttpStatusCode.BadRequest); }
public async Task <HttpResponseMessage> Post(CreateSession model) { if (model == null) { throw new ArgumentNullException("model"); } if (!ModelState.IsValid) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, ModelState)); } var success = await membershipService.InternalSignIn( model.Email.ToLower(CultureInfo.CurrentCulture), model.Password, model.RememberMe.GetValueOrDefault()); return(Request.CreateResponse(success ? HttpStatusCode.NoContent : HttpStatusCode.BadRequest)); }
public async Task <CreateSessionResult> CreateSession(string username, string password, string deviceId) { var client = Client; var data = new CreateSession() { Username = username, Password = password, DeviceId = deviceId }; var resp = await client.PostAsJsonAsync("api/sessions", data); if (!resp.IsSuccessStatusCode) { throw ApiClientException.FromResponse(resp); } var result = await resp.Content.ReadAsAsync <CreateSessionResult>(); return(result); }
public async Task <ActionResult> CreateSession(Session session) { if (ModelState.IsValid) { SessionService service = SessionService.GetInstance(); CreateSession newSession = new CreateSession() { title = session.Title, description = session.Description, eventId = session.EventId, initialDate = DateTime.Parse(session.StartDate), endDate = DateTime.Parse(session.EndDate), speakerName = session.SpeakerName, lastName = session.LastName, linkOfSpeaker = session.LinkOfSpeaker, userId = User.Identity.GetUserId() }; var res = await service.PostSessionAsync(newSession);// retorna o id da sessão que foi criado se quiser fazer redirect falta o nome da comunidade if (res.Success) { //Falta meter o redirect como deve ser //return Json(new { url = Constants.WebAPPAddress + "/Home/" }); return(Redirect(Request.UrlReferrer.PathAndQuery)); } else { //tratar do erro que ainda falta pode dar um erro na inserção ViewBag.Message = res.Message; } } return(PartialView("_CreateSession", session)); }
public object Post(CreateSession message) { using (var db = _connectionFactory.Open()) { var session = new Session { JournalId = message.JournalId, Name = message.Name, Description = message.Description, CreatedAt = DateTime.Now }; try { long sessionId = db.Insert(session, true); return new GeneralizedResponse {Message = "New Session Created! Id: " + sessionId}; } catch (Exception) { throw; } } }
public async Task <OperationResult <int> > PostSessionAsync(CreateSession item) { return(await Post(item)); }
public async Task <OperationResult <int> > UpdateSession(CreateSession item) { return(await Put(item)); }
public async Task <OperationResult <int> > DeleteSession(CreateSession item) { return(await Delete(item)); }
private void CreateSession(CreateSession createSession) { IActorRef sessionActor = Context.ActorSelection(SalesOrderActorRefs.SessionCollection).ResolveOne(TimeSpan.FromSeconds(10)).Result; sessionActor.Tell(createSession); }
public async Task Post([FromBody] CreateSession command) => await _commandDispatcher.DispatchAsync(command);
public NetAcceptor(CreateSession dlgtCreateSession, NetCmdQueue refCmdQueue) { m_dlgtCreateSession = dlgtCreateSession; m_refCmdQueue = refCmdQueue; }
public void CreateSession() { CreateSession createSession = new CreateSession(Context.ConnectionId, Context.User.Identity.Name); SalesOrderActorSystem.SalesOrderBridgeActor.Tell(createSession); }