public ActionResult New(string search) { ViewBag.Title = "Select house plan"; using (var dtx = new HeimContext()) { if (!String.IsNullOrWhiteSpace(search)) { search = search.Trim().ToLower(); } else { search = null; } var query = from item in dtx.Plans where (search == null || item.Name.ToLower().Contains(search)) && item.Floors.Count() > 0 orderby item.Name select new PlanViewModel { ID = item.ID, Name = item.Name, PreviewImage = item.PreviewImageFilePath, Area = item.Area }; NewProjectViewModel vm = new NewProjectViewModel { Search = search, Plans = query.ToList() }; return(View(vm)); } }
public async Task <IActionResult> Add([FromBody] NewProjectViewModel model) { try { if (!ModelState.IsValid) { return(StatusCode(400, ModelState)); } var result = await _service.Add(companyId : model.CompanyId, name : model.Name, projectType : model.ProjectType, start : model.Start, end : model.End, projectedEnd : model.ProjectedEnd); if (!result) { return(StatusCode(400, new { Message = $"Unable to add new Project: {model.Name}", Status = 400 })); } return(Ok()); } catch (Exception ex) { _logger.LogError(ex.Message); _logger.LogError(ex.StackTrace); return(StatusCode(500)); } }
public async override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); ViewModel = await NewProjectViewModel.Init(WorkspaceId); clientBinding = this.SetBinding(() => ViewModel.ClientName, () => SelectClientBit.TextField.Text); }
public ActionResult Create(NewProjectViewModel npvm) { npvm.AdminID = Convert.ToInt32(Session["CurrentUserID"]); npvm.DateOfStart = DateTime.Now; if (ModelState.IsValid) { if (npvm.Attachments != null) { if (Request.Files.Count >= 1) { var File = Request.Files[0]; var ImgByte = new Byte[File.ContentLength - 1]; File.InputStream.Read(ImgByte, 0, ImgByte.Length); var Base64String = Convert.ToBase64String(ImgByte, 0, ImgByte.Length); npvm.Attachments = Base64String; } } this.ps.InsertProject(npvm); return RedirectToAction("Index", "Home", new { area = "Admin" }); } else { ViewBag.Categories = db.categories.ToList(); ModelState.AddModelError("X", "Invalid"); return View(); } }
public NewProjectDialog() { InitializeComponent(); _viewModel = App.Container.Get <NewProjectViewModel>(); this.DataContext = _viewModel; }
public ActionResult Create() { IEnumerable <SelectListItem> ProjectTypes = new List <SelectListItem> { new SelectListItem() { Value = "Research", Text = "Research" }, new SelectListItem() { Value = "Development", Text = "Development" } }; ViewBag.ProjectType = ProjectTypes; var id = User.Identity.GetUserId(); var group = _context.Groups.SingleOrDefault(g => g.Student1Id == id || g.Student2Id == id); if (group == null) { return(RedirectToAction("MyIndex", "Groups")); } var groupId = group.Id; var viewModel = new NewProjectViewModel { GroupId = groupId, SubmissionDate = DateTime.Now.Date }; return(View(viewModel)); }
public ActionResult New(NewProjectViewModel vm) { if (ModelState.IsValid) { var fileName = this.SaveCroppedFeaturedImage(vm.CroppedImage); Project project = new Project { CategoryId = vm.CategoryId, Title = vm.Title, Content = vm.Content, UserId = User.Identity.GetUserId(), Slug = UrlService.URLFriendly(vm.Slug), CreationTime = DateTime.Now, ModificationTime = DateTime.Now, PhotoPath = fileName ?? null }; db.Projects.Add(project); db.SaveChanges(); TempData["SuccessMessage"] = "The project created successfully."; return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories.OrderBy(x => x.CategoryName).ToList(), "Id", "CategoryName"); return(View()); }
public void InsertProject(NewProjectViewModel pvm) { var Config = new MapperConfiguration(cfg => { cfg.CreateMap <NewProjectViewModel, Projects>(); }); IMapper mapper = Config.CreateMapper(); Projects projects = mapper.Map <NewProjectViewModel, Projects>(pvm); pr.InsertProject(projects); }
public ProjectViewModel(NewProjectViewModel model) { Name = model.Name; StartDate = model.StartDate; NumberOfIterations = model.NumberOfIterations; IncludeIterationZero = model.IncludeIterationZero; NumberOfWeeksInIteration = model.NumberOfWeeksInIteration; }
public NewProject() { NewProjectViewModel = new NewProjectViewModel(); InitializeComponent(); Loaded += OnLoaded; }
public NewProject(ProjectManager project_manager) { InitializeComponent(); NewProjectViewModel = new NewProjectViewModel(this); this.DataContext = _new_project_view_model; this.ProjectManager = project_manager; }
public virtual ActionResult NewStep2(NewProjectViewModel model) { if (model == null) { return(RedirectToAction("New")); } return(View("New_Step2", model)); }
public async override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); ViewModel = await NewProjectViewModel.Init(WorkspaceId); clientBinding = this.SetBinding(() => ViewModel.ClientName, () => SelectClientBit.TextField.Text); nameBinding = this.SetBinding(() => ViewModel.ProjectName, () => ProjectBit.TextField.Text, BindingMode.TwoWay); colorBinding = this.SetBinding(() => ViewModel.ProjectColor, () => ColorPicker.Adapter.SelectedColor, BindingMode.TwoWay).UpdateTargetTrigger("SelectedColorChanged"); }
public NewProjectDialog() { InitializeComponent(); if (!DesignerProperties.GetIsInDesignMode(this)) { _viewModel = App.Container.Get <NewProjectViewModel>(); this.DataContext = _viewModel; } }
public ActionResult Create() { NewProjectViewModel viewModel = new NewProjectViewModel { Project = new Project(), Categories = db.Categories.ToList() }; return(View(viewModel)); }
public IActionResult AddNewProjectPost(NewProjectViewModel projectModel) { if (!ModelState.IsValid) { ViewBag.StatusMessage = "Model błędny!"; return(View(nameof(AddNewProject), projectModel)); } HttpContext.Session.TryGetValue("User", out var creator); if (creator == null) { ViewBag.StatusMessage = "Błąd! Użytkownik nie został zapisany w sesji!"; return(View()); } var options = new JsonSerializerOptions { WriteIndented = true }; var user = JsonSerializer.Deserialize <UserDto>(creator, options); var dbUser = _context.CalendarroUsers.FirstOrDefault(t => t.UserId == user.UserId); if (dbUser == null) { ViewBag.StatusMessage = "Nie znaleziono użytkownika w bazie"; return(View()); } var project = new Projects { CreateDate = DateTime.Now, Description = projectModel.Description, FinishingDate = projectModel.FinishDate, ProjectName = projectModel.ProjectName, Creator = _context.CalendarroUsers.Find(user.UserId) }; _context.Projects.Add(project); _context.SaveChanges(); var projectRelation = new ProjectUserRelation { User = dbUser, Project = project }; _context.ProjectUserRelation.Add(projectRelation); _context.SaveChanges(); ViewBag.StatusMessage = "Zaakceptowano"; return(RedirectToAction("Index", "Home", new { projectId = project.ProjectId })); }
private static void RenameEverything(NewProjectViewModel viewModel, string stringToReplace, string unpackDirectory) { RenameFiles(unpackDirectory, stringToReplace, viewModel.ProjectName); UpdateSolutionContents(unpackDirectory, stringToReplace, viewModel.ProjectName); UpdateNamespaces(unpackDirectory, stringToReplace, viewModel.DifferentNamespace); }
public ActionResult Edit(int id) { var selectedItem = db.Projects.SingleOrDefault(p => p.Id == id); NewProjectViewModel viewModel = new NewProjectViewModel { Project = selectedItem, Categories = db.Categories.ToList() }; return(View(viewModel)); }
public ActionResult New(NewProjectViewModel vm) { if (ModelState.IsValid) { //Map the viewmodel values to the DB model and then save it Project newProject = Mapper.From(vm); newProject = projectRepo.Create(newProject); return(RedirectToAction("index")); } return(View(vm)); }
// New Project Form public ViewResult New() { // Dropdown List Group var groups = _context.Groups.ToList(); var viewModel = new NewProjectViewModel { Groups = groups, }; return(View()); // return Content("Hello World"); }
// GET: ProjectModel public ActionResult NewProjectModel() { var categoriesofProjects = _context.Categories.ToList(); var viewModel = new NewProjectViewModel() { CategoriesDts = categoriesofProjects }; return(View(viewModel)); }
public ActionResult New() { var model = new NewProjectViewModel() { Name = "New Project", IncludeIterationZero = true, NumberOfIterations = 10, NumberOfWeeksInIteration = 2, StartDate = FirstWednesdayAfterToday() }; return(View("New", model)); }
public NewProjectWindow() { this.InitializeComponent(); Instance = this; this.ViewModel = new NewProjectViewModel() { ProjectName = "My Project", ProjectPath = @"C:\Starbound" }; this.DataContext = this.ViewModel; this.projectNameTextBox.Watermark = "My Project"; this.projectPathTextBox.Watermark = @"C:\Starbound"; }
private static string GetFileToDownload(NewProjectViewModel viewModel) { PlatformProjectInfo foundInstance = viewModel.ProjectType; if (foundInstance == null) { throw new NotImplementedException("You must first select a template"); } else { return(foundInstance.Url); } }
public async override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); if (viewModel == null) { var timeEntryList = BaseActivity.GetDataFromIntent <List <TimeEntryData> > (Activity.Intent, NewProjectActivity.ExtraTimeEntryDataListId); viewModel = new NewProjectViewModel(timeEntryList); } viewModel.OnIsLoadingChanged += OnModelLoaded; await viewModel.Init(); }
public ActionResult Create(NewProjectViewModel model) { if (ModelState.IsValid) { _apiService.CreateProject(new NewProjectDto { Alias = model.Alias, DefaultBranchName = model.DefaultBranchName, Name = model.DisplayName }); } return(RedirectToAction("Index")); }
public void CreateNewProjectViewModel_Test() { // Arrange var customerList = GenerateCustomersName(); // Act var newProjectVM = new NewProjectViewModel(_events, _projectAccess, _customerAccess); newProjectVM.LoadCustomers_Run(); // Assert Assert.IsType <BindableCollection <string> >(newProjectVM.CustomersName); Assert.True(newProjectVM.CustomersName.Count == customerList.Count); }
public NewProjectPage(bool returnToPreviousPage = false) { ReturnToPreviousPage = returnToPreviousPage; NavigationPage.SetBackButtonTitle(this, ""); //HockeyApp.MetricsManager.TrackEvent("NewProjectPage Initialize"); InitializeComponent(); viewModel = new NewProjectViewModel(); viewModel.StartDate = DateTime.Now.Date; StartLoading(); BindingContext = viewModel; }
private static bool DownloadFileSync(NewProjectViewModel viewModel, string zipToUnpack, string fileToDownoad) { EmbeddedExecutableExtractor eee = EmbeddedExecutableExtractor.Self; eee.ExtractFile("FlatRedBall.Tools.dll"); eee.ExtractFile("Ionic.Zip.dll"); eee.ExtractFile("Ionic.Zlib.dll"); string resultingLocation = eee.ExtractFile("FRBDKUpdater.exe"); UpdaterRuntimeSettings urs = new UpdaterRuntimeSettings(); urs.FileToDownload = fileToDownoad; urs.FormTitle = "Downloading " + viewModel.ProjectType.FriendlyName; if (string.IsNullOrEmpty(zipToUnpack)) { throw new Exception("The zipToUnpack argument is null - it shouldn't be"); } urs.LocationToSaveFile = zipToUnpack; string whereToSaveSettings = FileManager.UserApplicationDataForThisApplication + "DownloadInformation." + UpdaterRuntimeSettings.RuntimeSettingsExtension; urs.Save(whereToSaveSettings); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = resultingLocation; // The username for the user may have a space in it // so we need to have quotes around the path psi.Arguments = "\"" + whereToSaveSettings + "\""; Process process = Process.Start(psi); while (!process.HasExited) { System.Threading.Thread.Sleep(200); } bool succeeded = process.ExitCode == 0; return(succeeded); }
public override void Execute(object parameter) { var settings = new Dictionary <string, object> { { "SizeToContent", SizeToContent.Manual }, { "MinWidth", 784 }, { "MinHeight", 411 }, { "Width", 939 }, { "Height", 621 }, { "ShowInTaskbar", false } }; var newProjectVm = new NewProjectViewModel(); Editor.Current.WindowManager.ShowDialog(newProjectVm, null, newProjectVm.GetDialogSettings()); }