예제 #1
0
        public async Task <IActionResult> UploadSolution([Bind("OrderId, Solution, uploadedFile")] UploadSolutionViewModel upSolution)
        {
            Order order = _repository.GetOrdersById(upSolution.OrderId);

            order.Solution = upSolution.Solution;

            if (upSolution.uploadedFile != null)
            {
                string now = DateTime.Now.ToString("ddHHmmss");

                string path = "/Files/" + now + upSolution.OrderId + upSolution.uploadedFile.FileName;

                using (var fileStream = _repository.getFilestream(_appEnvironment.WebRootPath + path, FileMode.Create))
                {
                    await upSolution.uploadedFile.CopyToAsync(fileStream);
                }
                FileModel file = new FileModel {
                    Name = now + upSolution.OrderId + upSolution.uploadedFile.FileName, Path = path
                };


                order.NumberOfStrings = _repository.getNumberOfStrings(_appEnvironment.WebRootPath + path);

                order.SolutionFile = _repository.AddFile(file);
            }
            order.Status = 1;

            _repository.saveSolution(order);

            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
        //UploadSolution get
        public IActionResult UploadSolution(int id)
        {
            Order order = _repository.GetOrdersById(id);
            UploadSolutionViewModel upSolution = new UploadSolutionViewModel();

            upSolution.OrderId        = id;
            upSolution.OrderName      = order.OrderName;
            upSolution.OrderTask      = order.OrderTask;
            upSolution.ClientName     = order.Client.UserName;
            upSolution.DateOfDeadline = order.DateOfDeadline;
            return(View(upSolution));
        }