Exemple #1
0
        public async Task <IActionResult> AddThread(int albumId, Thread model, IFormFile file, string tags)
        {
            //the type of files that the system ONLY accepts
            if (file.ContentType == "image/jpeg" || file.ContentType == "image/png")
            {
                var userId = _userManager.GetUserId(User);                           //gets the usersId
                var user   = await _userManager.FindByIdAsync(userId);               //gets the userName

                var thread = _service.Create(model, user, albumId);                  //creates the thread
                _service.ChangeTags(thread.Result, tags);
                var threadId = thread.Result.ID;                                     //gets the Threads id
                await _service.AssignCords(file, threadId);                          //assignes the cords from the picture
                await UploadThreadImage(file, threadId);                             //uploads the threadImage

                return(RedirectToAction("Index", "Thread", new { @id = threadId })); //shows the thread that was created
            }
            return(View("../Shared/Error"));
        }