public async Task <RegistrationModel> OnRegistration(RegistrationInputModel input) { RegistrationModel result = new RegistrationModel(); if (string.IsNullOrEmpty(input.username) || string.IsNullOrEmpty(input.firstName) || string.IsNullOrEmpty(input.lastName) || string.IsNullOrEmpty(input.password)) { result.GenerateError("Неки од података фале!"); return(result); } // check if there is account with same username var db = ARDirect.Instance; if (await ARDirect.Instance.Query <ClientDM>().Where("username={0}", input.username).CountAsync() > 0) { result.GenerateError("Корисничко име је заузето. Одаберите неко друго!"); return(result); } ClientDM client = new ClientDM(db) { username = input.username, password = DirectPassword.Hash(input.password), firstName = input.firstName, lastName = input.lastName }; await client.InsertAsync(); this.Notify(Sockets.Dashboard.Models.DashboardModel.FunctionTypes.notifySuccess, $"Нови корисник се регистровао: '${client.username}'!"); return(result); }
public ActionResult CreateUser(string username, string password) { ClientDM client = new ClientDM() { username = username, password = DirectPassword.Hash(password), firstName = "firstname", lastName = "lastname" }; client.InsertAsync(); client.WaitIDExplicit(10); return(this.Content("Userid: " + client.ID.Value)); }
public async Task <LoginModel> Index(LoginInputModel input) { var result = new LoginModel(); if (string.IsNullOrEmpty(input.username) || string.IsNullOrEmpty(input.password)) { result.GenerateError("Неки од података фале!"); return(result); } ClientDM client = await ARDirect.Instance.Query <ClientDM>().Where("username={0}", input.username).LoadSingleAsync(); if (client == null) { result.GenerateError("Не постоји налог са корисничким именом!"); return(result); } if (!DirectPassword.Verify(input.password, client.password)) { result.GenerateError("Погрешна шифра!"); return(result); } ClientSessionDM session = new ClientSessionDM() { clientid = client.ID.Value }; await session.InsertAsync(); session.WaitID(3); result.clientID = client.ID.Value; result.session = session.clientSessionGuid.ToString(); result.username = client.username; result.firstName = client.firstName; result.lastName = client.lastName; result.profilePic = client.profilePic; this.Notify(Sockets.Dashboard.Models.DashboardModel.FunctionTypes.notifySuccess, $"Korisnik '${client.username}' se ulogovao!"); AndroidSocketManager.Current.Send(FitAR.Sockets.Models.AndroidSocketMessage.Construct("text", "green", new FitAR.Sockets.Models.AndroidSocketTextMessage() { text = $"Korisnik '${client.username}' se ulogovao!" })); return(result); }
public async Task <AnchorResponseModel> Index(AnchorModel input) { var db = ARDirect.Instance; var response = new AnchorResponseModel(); ClientSessionDM session = await db.Query <ClientSessionDM>().Where("clientSessionGuid={0}", input.sessionid).LoadSingleAsync(); if (session == null) { response.GenerateError("Sesija ne postoji"); return(response); } ClientDM client = await db.Query <ClientDM>().Where("clientid={0}", session.clientid).LoadSingleAsync(); AnchorDM anchor = new AnchorDM() { clientid = session.clientid, clientsessionid = session.clientSessionID, sessionid = input.anchorid, noteText = input.noteText, lat = input.lat, lng = input.lng }; await anchor.InsertAsync(); AndroidSocketManager.Current.Send(FitAR.Sockets.Models.AndroidSocketMessage.Construct("text", "green", new FitAR.Sockets.Models.AndroidSocketTextMessage() { text = $"Korisnik '{client.username}' je postavio poruku '{input.noteText}'." })); DashboardSocketHandler.Current?.SendToAll(new DashboardModel() { Function = DashboardModel.FunctionTypes.notifyInverse, RequireReload = false, Text = $"Korisnik '{client.username}' je postavio poruku '{input.noteText}'." });; return(response); }
public AndroidSocket(AndroidSocketManager manager, ClientSessionDM session) { this.manager = manager; this.session = session; this.client = ARDirect.Instance.Query <ClientDM>().Where("clientid={0}", session.clientid).LoadSingle(); }
public async Task <ActionResult> UploadImage(IFormFile file, string username) { Console.WriteLine("--> ML:: Receiving file"); if (file == null || file.Length == 0 || !CheckIfImageFile(file)) { return(this.BadRequest()); } ClientDM clientDM = await ARDirect.Instance.Query <ClientDM>().Where("username={0}", username).LoadSingleAsync(); if (clientDM == null) { return(this.BadRequest()); } try { byte[] fileBytes; var ms = new MemoryStream(); file.CopyTo(ms); fileBytes = ms.ToArray(); string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=paywall;AccountKey=hDfRSqohMj3NdKjtJhYn2zAnxR7eAZ3dQidDviGnHDPBLEZwfp1ptbPFfvBdjfEqsfmZEboXOyd4s9wUJZDcfA==;EndpointSuffix=core.windows.net"; CloudStorageAccount storageacc = CloudStorageAccount.Parse(storageConnectionString); CloudBlobClient client = storageacc.CreateCloudBlobClient(); CloudBlobContainer cont = client.GetContainerReference("aco"); await cont.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); string extension = ""; switch (ImageUploadHelper.GetImageFormat(fileBytes)) { case ImageUploadHelper.ImageFormat.jpeg: extension = ".jpg"; break; case ImageUploadHelper.ImageFormat.png: extension = ".png"; break; default: return(this.BadRequest()); } Stream inputStream = ms; string ImageName = "profile_" + Guid.NewGuid().ToString().Replace("-", string.Empty) + extension; CloudBlockBlob cblob = cont.GetBlockBlobReference(ImageName); await cblob.UploadFromStreamAsync(inputStream); clientDM.profilePic = cblob.Uri.AbsoluteUri; await clientDM.UpdateAsync(); return(this.Ok()); } catch (Exception e) { return(this.BadRequest()); } }