Exemplo n.º 1
0
        public IActionResult EditFile(int fileId, IFormFile file)
        {
            StoredFileDTO fileById       = _fileLogic.GetFileById(fileId);
            bool          hasNameChanged = fileById.FileName.Equals(file.FileName);
            string        newFileName    = _fileLogic.UpdateFile(new StoredFileDTO
            {
                Id         = fileId,
                FileName   = file.FileName,
                FileSize   = _shareControllerHelper.FormatSize(file.Length),
                UploadDate = DateTime.Now,
                UserId     = _accountLogic.GetCurentUserById()
            }, !hasNameChanged);

            _fileLogic.ReplaceFileOnDisk(file, _uploads, !hasNameChanged, newFileName);
            return(RedirectToAction("Files"));
        }
Exemplo n.º 2
0
        private void CheckEditFile(TextBox a, TextBox b)
        {
            if (String.IsNullOrEmpty(a.Text) || String.IsNullOrEmpty(b.Text))
            {
                MessageBox.Show("Invalid values entered. Check the input, please");
            }

            else if (OldTitleBox.Text == NewTitleBox.Text)
            {
                MessageBox.Show("Same values entered. Check the input, please");
            }

            else if (fileLogic.GetTitleForDelete(id1, a.Text) == 0)
            {
                MessageBox.Show("Old title is incorrect. Check the input, please");
            }
            else
            {
                fileLogic.UpdateFile("UpdateFile", OldTitleBox.Text, NewTitleBox.Text, id1);
            }
        }