public static Folder Map(CreateFolderViewModel viewModelFolder) { return(new Folder() { Path = viewModelFolder.Path + "/" + viewModelFolder.Name }); }
public void CreateFolder(CreateFolderViewModel model) { if (ModelState.IsValid) { string uid = User.Identity.GetUserId(); Folder f = new Folder(); SqlCommand command = new SqlCommand( "INSERT INTO Folder (ID, Name, UserID) " + "VALUES (@id, @name, @userid)"); SqlParameter FID = new SqlParameter { ParameterName = "@id", Value = f.ID }; SqlParameter NME = new SqlParameter { ParameterName = "@name", Value = model.Name }; SqlParameter UID = new SqlParameter { ParameterName = "@userid", Value = uid }; command.Parameters.Add(FID); command.Parameters.Add(NME); command.Parameters.Add(UID); Utility.Constants.CallDB(command); } }
public async Task <IActionResult> CreateFolder(CreateFolderViewModel folder) { CreateFolderResult result = await _mediatr.Send(new CreateFolderCommand(folder.FolderName, folder.ParentFolder.Id)); if (result.State == OperationState.Success) { return(Created($"{BaseUrl}/folder={result.Folder.Id}", result.Folder)); } else { return(HandleResult(result)); } }
public ActionResult Create(CreateFolderViewModel viewModel) { if (!ModelState.IsValid) { return(PartialView("ErrorsList", ProceedModelState())); } Folder folder = FolderMapper.Map(viewModel); try { FoldersService.CreateFolder(folder.Path); } catch (Exception exception) { return(PartialView("ErrorsList", ProcessException(exception))); } return(GetFolderView(viewModel.Path)); }
public CreateFolderView() { InitializeComponent(); _viewModel = new CreateFolderViewModel(); DataContext = _viewModel; }