Esempio n. 1
0
        public CreationResult <Project> Create(EditProject editModel)
        {
            if (string.IsNullOrEmpty(editModel.Name))
            {
                return(CreationResult.Fail <Project>("Project name is required."));
            }
            var currentModel = _masterModelRepository.GetCurrent();

            if (IsProjectNameAlreadyUsed(editModel.Name, currentModel))
            {
                return(CreationResult.Fail <Project>(NameCollisionMessage(editModel.Name)));
            }

            var project = currentModel.CreateProject(x =>
            {
                x.Name = editModel.Name;
                x.CruiseProjectAssociations =
                    editModel.SafeProjects.Select(
                        cp => new CruiseProjectAssociation {
                    ServerId = cp.Server, Name = cp.Project
                })
                    .ToArray();
            });

            _masterModelRepository.Save(currentModel);

            return(CreationResult.Success(project));
        }
Esempio n. 2
0
            public void ContextSetup()
            {
                var existingMasterModel = new MasterModel();

                _serverId = Guid.NewGuid();
                var existingCruiseProjectAssociations = new[]
                {
                    new CruiseProjectAssociation {
                        ServerId = _serverId, Name = "Project Foo"
                    },
                };
                var projectToEdit = existingMasterModel.CreateProject(x =>
                {
                    x.Name = "Existing Project";
                    x.CruiseProjectAssociations = existingCruiseProjectAssociations;
                });

                _expectedId = projectToEdit.Id;

                var repository = new StubMasterModelRepository();

                repository.UseCurrentModel(existingMasterModel);

                var manager   = new ProjectManager(repository);
                var editModel = new EditProject
                {
                    ProjectId      = projectToEdit.Id,
                    Name           = "Existing Project",
                    CruiseProjects = null,
                };

                _result = manager.Update(editModel);

                _savedModel = repository.LastSaved;
            }
        public OperationResult Edit(EditProject command)
        {
            var operation = new OperationResult();
            var project   = _projectRepository.GetProjectWithCategory(command.Id);

            if (project == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }

            if (_projectRepository.Exist(x => x.Name == command.Name && x.Id != command.Id))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }
            var slug        = command.Slug.Slugify();
            var picturePath = $"{"Project"}/{slug}";

            var firstPicture  = _fileUploader.Upload(command.FirstPicture, picturePath);
            var secondPicture = _fileUploader.Upload(command.SecondPicture, picturePath);
            var thirdPicture  = _fileUploader.Upload(command.ThirdPicture, picturePath);
            var forthPicture  = _fileUploader.Upload(command.ForthPicture, picturePath);

            project.Edit(command.Name, command.Customer, command.Technology, firstPicture, secondPicture, thirdPicture, forthPicture,
                         command.PictureAlt, command.PictureTitle, command.Slug, command.UrlLink, command.CategoryId, command.Description);

            _projectRepository.SaveChanges();

            return(operation.Succedded());
        }
Esempio n. 4
0
        public async Task <IActionResult> EditProject([FromForm]
                                                      [Bind("Unique_ProjectIdString", "ProjectName", "ProjectClient", "ProjectDescription", "ProjectActive", "ProjectCompleted", "ProjectPlannedStart", "ProjectPlannedEnd")]
                                                      EditProject model)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(User);

                model.user = user.UserName;

                if (await _projectRepository.EditProjectAsync(model))
                {
                    TempData["success"] = string.Format("Prosjekt {0} er oppdatert!", model.ProjectName);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    TempData["error"] = string.Format("Prosjekt {0} er ikke oppdatert. Ingen endringer oppdaget!", model.ProjectName);
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                TempData["error"] = "Feil med mottatt data. ModelStateInvalid!";
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 5
0
        public EditResult <Project> Update(EditProject editModel)
        {
            var currentModel = _masterModelRepository.GetCurrent();
            var project      = currentModel.Projects.SingleOrDefault(x => x.Id.Equals(editModel.ProjectId.Value));

            if (project == null)
            {
                return(CouldNotLocateProject(editModel.ProjectId.Value));
            }

            var existingProjectWithThisName = currentModel.Projects.SingleOrDefault(x => x.Name.Equals(editModel.Name));

            if (existingProjectWithThisName != null && existingProjectWithThisName.Id != editModel.ProjectId)
            {
                return(EditResult.Fail <Project>(NameCollisionMessage(editModel.Name)));
            }

            project.Name = editModel.Name;
            if (editModel.CruiseProjects == null)
            {
                project.CruiseProjectAssociations = new CruiseProjectAssociation[0];
            }
            else
            {
                project.CruiseProjectAssociations = editModel.CruiseProjects
                                                    .Select(
                    cp => new CruiseProjectAssociation {
                    Name = cp.Project, ServerId = cp.Server
                })
                                                    .ToArray();
            }
            _masterModelRepository.Save(currentModel);

            return(EditResult.Success(project));
        }
Esempio n. 6
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();
        currentFilePath = "";
        MW   = this;
        egrp = new EditGroup();
        egrp.ShowAll();
        eprj = new EditProject();
        eprj.ShowAll();
        eunt = new EditUnit();
        eunt.ShowAll();
        ecpmd = new EditCompuMethod();
        ecpmd.ShowAll();
        emsg = new EditMessage();
        emsg.ShowAll();
        eprc = new EditProcess();
        eprc.ShowAll();
        etsk = new EditTask();
        etsk.ShowAll();
        esm = new EditStateMachine();
        esm.ShowAll();

        ts = new Gtk.TreeStore(typeof(string));
        this.treeviewGlobal.Model = ts;

        Gtk.TreeViewColumn prjColumn = new Gtk.TreeViewColumn();
        prjColumn.Title = "EasyOS";

        Gtk.CellRendererText projectCell = new Gtk.CellRendererText();
        prjColumn.PackStart(projectCell, true);
        prjColumn.AddAttribute(projectCell, "text", 0);
        treeviewGlobal.AppendColumn(prjColumn);

        treeviewGlobal.Visible    = false;
        this.alignFrmEditor.Child = eprj;
        this.frmEditor.ShowAll();
        this.frmEditor.Visible = false;

        this.addAction.Sensitive      = false;
        this.deleteAction.Sensitive   = false;
        this.generateAction.Sensitive = false;
        this.GenerateAction.Sensitive = false;
        this.saveAction.Sensitive     = false;
        this.SaveAction.Sensitive     = false;
        this.saveAsAction.Sensitive   = false;
        this.SaveAsAction.Sensitive   = false;
        this.refreshAction.Sensitive  = false;
    }
Esempio n. 7
0
        public ActionResult Edit(int id)
        {
            var service = CreateProjectService();
            var detail  = service.GetProjectById(id);
            var model   =
                new EditProject
            {
                Name          = detail.Name,
                TypeOfProject = detail.TypeOfProject,
                Notes         = detail.Notes,
                ProjectID     = detail.ProjectID,
                OwnerId       = detail.OwnerId,
                CustomerID    = detail.CustomerID
            };

            return(View(model));
        }
        /// <summary>
        /// function that creates view edit project
        /// </summary>
        /// <param name="id"> project id</param>
        /// <returns>returns updated model to show in the view</returns>
        public EditProject EditProjView(int?id)
        {
            ReviseDBEntities con = new ReviseDBEntities();      //connection to the DB
            var uRepo            = new AssignUserRepository();  //gets user list to assign
            var rRepo            = new RemoveUsers();           //gets user list to remove

            var ShowView = new EditProject()
            {
                AssignUser = uRepo.GetUsers(id),
                RemoveUser = rRepo.GetUsers(id),
                projid     = id ?? default(int),
                projname   = con.projects.Find(id).ProjName,
                projdesc   = con.projects.Find(id).description,
            };

            return(ShowView);
        }
Esempio n. 9
0
        public bool UpdateProject(EditProject model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Project
                    .Single(e => e.ProjectID == model.ProjectID && e.OwnerId == _userId);

                entity.Name          = model.Name;
                entity.TypeOfProject = model.TypeOfProject;
                entity.Notes         = model.Notes;
                entity.ProjectID     = model.ProjectID;
                entity.OwnerId       = model.OwnerId;
                entity.CustomerID    = model.CustomerID;

                return(ctx.SaveChanges() == 1);
            }
        }
Esempio n. 10
0
        // TODO: Edit all updates correct -ie comleted, active...
        public async Task <bool> EditProjectAsync(EditProject project)
        {
            Project p = await GetProjectByUniqueId(project.Unique_ProjectIdString);

            if (project.ProjectName != p.ProjectName)
            {
                p.ProjectName = project.ProjectName;
            }
            if (project.ProjectClient != p.ProjectClient)
            {
                p.ProjectClient = project.ProjectClient;
            }
            if (project.ProjectDescription != p.ProjectDescription)
            {
                p.ProjectDescription = project.ProjectDescription;
            }
            if (project.ProjectActive != p.ProjectActive)
            {
                p.ProjectActive = project.ProjectActive;
            }
            if (project.ProjectCompleted != p.ProjectCompleted)
            {
                p.ProjectCompleted = project.ProjectCompleted;
            }
            if (project.ProjectPlannedEnd != p.ProjectPlannedEnd)
            {
                p.ProjectPlannedEnd = project.ProjectPlannedEnd;
            }
            if (project.ProjectPlannedStart != p.ProjectPlannedStart)
            {
                p.ProjectPlannedStart = project.ProjectPlannedStart;
            }

            _db.Update(p);
            if (await _db.SaveChangesAsync() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        public ActionResult EditProject(EditProject editModel)
        {
            ICrudResult <Project> result;

            if (editModel.ProjectId == null || editModel.ProjectId.Value == Guid.Empty)
            {
                result = _projectManager.Create(editModel);
            }
            else
            {
                result = _projectManager.Update(editModel);
            }
            if (result.IsSuccessful)
            {
                return(RedirectToAction("Index"));
            }
            TempData["ErrorMessage"] = result.Message;
            return(RedirectToAction("EditProject",
                                    new { projectId = editModel.ProjectId, projects = editModel.CruiseProjects }));
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method handles selection changes in assembly references.</summary>
 ///
 /// <param name="sender">Sender of the event.</param>
 /// <param name="e">Event arguments.</param>
 ///--------------------------------------------------------------------------------
 void ProjectReference_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (sender is ProjectReferenceViewModel)
     {
         // TODO: figure out why IsSelected isn't synching up with two way binding between multi select listbox and ProjectReferenceList
         // by the time OnUpdate is called, which is the reason for this workaround method
         ProjectReferenceViewModel changedView       = sender as ProjectReferenceViewModel;
         ProjectReference          existingReference = ProjectReferenceList.Find("ReferencedProjectID", changedView.ReferencedProjectID);
         if (existingReference == null && changedView.IsSelected == true)
         {
             ProjectReferenceList.Add(changedView.ProjectReference);
         }
         else if (changedView.IsSelected == false)
         {
             ProjectReferenceList.Remove(existingReference);
         }
         ProjectReferencesModified = true;
         OnPropertyChanged("ProjectReferenceList");
         OnPropertyChanged("EditProject");
         EditProject.ResetModified(true);
     }
 }
        public ActionResult Edit(EditProject model)
        {
            if (ModelState.IsValid)
            {
                Project project = projectRepository.GetById(model.Id);

                project.Description       = model.Description;
                project.EndDate           = model.EndDate;
                project.ResponsibleUserId = model.ResponsibleUserId;
                project.StartDate         = model.StartDate;
                project.Tile = model.Tile;

                try
                {
                    projectRepository.Update(project);
                    projectRepository.SaveChanges();
                }
                catch (Exception e)
                {
                    TempData["IsSuccess"] = false;
                    TempData["Message"]   = "Что-то пошло не так и проект не был сохранен.";
                    return(RedirectToAction("Index"));
                }


                TempData["IsSuccess"] = true;
                TempData["Message"]   = "Проект успешно сохранен!";
            }
            else
            {
                TempData["IsSuccess"] = false;
                TempData["Message"]   = "Этап проекта не был создан, т.к. не заполнены все поля. Пожалуйста повторите попытку заполнив все поля.";
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 14
0
        public ActionResult Edit(int id, EditProject model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ProjectID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateProjectService();

            if (service.UpdateProject(model))
            {
                TempData["SaveResult"] = "Your note was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your note could not be updated.");
            return(View(model));
        }
Esempio n. 15
0
        public IActionResult OnPost(EditProject command)
        {
            var project = _projectApplication.Edit(command);

            return(RedirectToPage("./Index"));
        }
Esempio n. 16
0
 public void OnGet(long id)
 {
     Command           = _projectApplication.GetDetails(id);
     ProjectCategories = new SelectList(_projectCategoryApplication
                                        .GetProjectCategory(), "Id", "Name");
 }
        public void Put(Project value)
        {
            IEdit edit = new EditProject();

            edit.EditProjectByID(value);
        }