Ejemplo n.º 1
0
        public int InsertNewUser(SignUpModel sentNewUser)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@USERNAME", sentNewUser.Username),
                new SqlParameter("@EMAIL", sentNewUser.Email),
                new SqlParameter("@PASSWORD", sentNewUser.Password),
                new SqlParameter("@PROFILEURL", sentNewUser.ProfilePicURL)
            };

            return ExecuteSPNonReturnData("InsertNewUser", parameters, "@NEW_IDENTITY");
        }
Ejemplo n.º 2
0
 public int Post(SignUpModel sentNewUser)
 {
     return new SignUpModel().InsertNewUser(sentNewUser);
 }
Ejemplo n.º 3
0
        public override Task ExecutePostProcessingAsync()
        {
            //Calling this method for new registration
            SignUpModel signUp = new SignUpModel();
            PostsModel newPost = new PostsModel();

            bool isASignUp = false;
            bool isAPhotoPost = false;

            // NOTE: FileData is a property of MultipartFileStreamProvider and is a list of multipart
            // files that have been uploaded and saved to disk in the Path.GetTempPath() location.

            foreach (var fileData in FileData)
            {

                if (fileData.Headers.ContentDisposition.FileName == null)
                {
                    //do something here with the form data
                    var pair = fileData.Headers.ContentDisposition.Name.Trim('"').Split('-');
                    switch (pair[0])
                    {
                        case("uname"):
                            signUp.Username = pair[1];
                            isASignUp = true;
                            break;
                        case("email"):
                            signUp.Email = pair[1];
                            isASignUp = true;
                            break;
                        case("pass"):
                            signUp.Password = pair[1];
                            isASignUp = true;
                            break;
                        case ("userid"):
                            newPost.UserId = Convert.ToInt32(pair[1]);
                            isAPhotoPost = true;
                            break;
                        case ("filtername"):
                            newPost.Filter = pair[1];
                            isAPhotoPost = true;
                            break;
                        case ("guid"):
                            newPost.Guid = pair[1];
                            isAPhotoPost = true;
                            break;
                    }
                    continue;
                }
                
                // Sometimes the filename has a leading and trailing double-quote character
                // when uploaded, so we trim it; otherwise, we get an illegal character exception
                var fileName = Path.GetFileName(fileData.Headers.ContentDisposition.FileName.Trim('"'));

                //signUp.Password = pair[1];

                // Retrieve reference to a blob
                var blobContainer = BlobHelper.GetBlobContainer();
                var blob = blobContainer.GetBlockBlobReference(fileName);

                // Set the blob content type
                blob.Properties.ContentType = fileData.Headers.ContentType.MediaType;

                // Upload file into blob storage, basically copying it from local disk into Azure
                using (var fs = File.OpenRead(fileData.LocalFileName))
                {
                    //APPLY FILTERS HERE 
                    string passedFilter = string.IsNullOrEmpty(newPost.Filter) ? "" : newPost.Filter;

                    //convert stream into image, and apply filter                    
                    Image filterApplied = UGoFilters.ApplyFilter(passedFilter, Image.FromStream(fs));

                    //convert image to stream and upload
                    blob.UploadFromStream(Compression.ToStream(filterApplied, 75));
                }

                // Delete local file from disk
                File.Delete(fileData.LocalFileName);

                //Adding New User
                int id = 0;
                if (isASignUp)
                { 
                    signUp.ProfilePicURL = blob.Uri.AbsoluteUri;
                    id = new SignUpModel().InsertNewUser(signUp);
                }
                //Adding a New Post
                else if (isAPhotoPost)
                {
                    newPost.PostedImage = blob.Uri.AbsoluteUri;
                    new PostsModel().InsertPhotoPost(newPost);
                }

                // Create blob upload model with properties from blob info
                var blobUpload = new BlobUploadModel
                {
                    FileName = blob.Name,
                    FileUrl = blob.Uri.AbsoluteUri,
                    FileSizeInBytes = blob.Properties.Length,
                    CustomData = id.ToString()
                };


                // Add uploaded blob to the list
                Uploads.Add(blobUpload);
            }

            return base.ExecutePostProcessingAsync();
        }
Ejemplo n.º 4
0
 public int InsertNewUser(SignUpModel sentNewUser)
 {
     return new SignUpDAL().InsertNewUser(sentNewUser);
 }