public IActionResult Edit(UploadEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Upload upload = _uploadRepository.GetUpload(model.Id);

                upload.Name        = model.Name;
                upload.Description = model.Description;
                //upload.Department = model.Department;

                if (model.Project != null)
                {
                    if (model.ExistingUploadPath != null)
                    {
                        string filePath = Path.Combine(hostingEnvironment.WebRootPath,
                                                       "projects", model.ExistingUploadPath);
                        System.IO.File.Delete(filePath);
                    }

                    upload.UploadPath = ProcessUploadedFile(model);
                }


                _uploadRepository.Update(upload);

                return(RedirectToAction("index"));
            }

            return(View(model));
        }
Esempio n. 2
0
 public DataModel.Response.BaseResponse UpdateUpload(DataModel.Model.UploadModel upload)
 {
     try
     {
         IUploadRepository uploadRepository = RepositoryClassFactory.GetInstance().GetUploadRepository();
         Upload            _upload          = MapperUtil.CreateMapper().Mapper.Map <UploadModel, Upload>(upload);
         uploadRepository.Update(_upload);
         return(new BaseResponse
         {
             ErrorCode = (int)ErrorCode.None,
             Message = Resources.Resource.msg_update_success
         });
     }
     catch (Exception ex)
     {
         return(new BaseResponse
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }
Esempio n. 3
0
 public Upload Update(Upload upload)
 {
     return(_uploadRepository.Update(upload.Map <DbUpload>()).Map <Upload>());
 }