public ActionResult Edit(ProjectEditModel model) { var files = Request.Files; try { if (files.Count > 0) { var file0 = files[0]; var relativePath = FilesHelper.RelativePath; var path = Server.MapPath(relativePath); ProjectOperations.CreateUpdate(model.details, files[0], path, true); } else { ProjectOperations.CreateUpdate(model.details, null, "", true); } //ProjectOperations.CreateUpdate(model.details, true); return(RedirectToAction("Index", new { Type_ID = model.filter.Type_ID, SubType_ID = model.filter.SubType_ID, InMailingListOnly = model.filter.InMailingListOnly })); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(View(model)); } }
public ActionResult Create(ProjectEditModel model) { SaveEditModel(model); Info("Prosjekt {0} ble Lagret", model.ProjectName); return(RedirectToAction("Index", "Customer")); }
public ActionResult Edit(int Id, int?type_ID, int?subType_ID, bool inMailingListOnly) { Project card = ProjectOperations.GetProjectById(Id); if (card == null) { return(RedirectToAction("Index", new { Type_ID = type_ID, SubType_ID = subType_ID, InMailingListOnly = inMailingListOnly })); } ProjectEditModel model = ProjectOperations.GetProjectEditModel(card); model.filter = new EventsFilterViewModel_ForList { Type_ID = type_ID, SubType_ID = subType_ID, InMailingListOnly = inMailingListOnly }; model.eventsFilter = new EventsFilterViewModel_ForCard() { Category_ID = 1, Card_ID = Id }; model.projectFilter = new ProjectFilterViewModel_ForCard() { ID = card.ID }; return(View(model)); }
public async Task <IActionResult> AddProject(ProjectEditModel model) { if (ModelState.IsValid) { try { // Create post entity var project = _mapper.Map <Project>(model); var record = await _context.Projects.FirstOrDefaultAsync(q => q.ProjectId != model.ProjectId && q.Slug == model.Slug); if (record == null) { // Populate unmapped properties project.Slug = model.Slug; project.DateCreated = DateTime.UtcNow; // Add _context.Projects.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction("Projects", "Dashboard")); } ModelState.AddModelError("slug", "Slug must be unique"); } catch { ModelState.AddModelError("", "An error occurred while adding the post"); } } return(View("ProjectRecord", model)); }
public ActionResult Edit(ProjectEditModel model) { if (!ModelState.IsValid) { string messages = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage + x.Exception)); this.AddNotification(messages, NotificationType.ERROR); return(View(model)); } try { var info = ExtractEditFormData(model); var isSuccess = _mainStore.Update(info); CachingHelpers.ClearProjectCache(info.Id); if (isSuccess) { this.AddNotification(ManagerResource.LB_UPDATE_SUCCESS, NotificationType.SUCCESS); } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for Edit Product request: " + ex.ToString()); return(View(model)); } return(RedirectToAction("Edit/" + model.Id)); }
public ProjectEditModel GetProjectEditModel(Project Project) { //HolidayLocation hol1 = new HolidayLocation ; //holidayLocation.Add(hol); ProjectDetailsModel details = new ProjectDetailsModel { ID = Project.ID, Name = Project.Name, Project_Description = Project.Comments, ImageName = Project.ImageName, ImageOriginalName = Project.ImageOriginalName }; ProjectEditModel editModel = new ProjectEditModel(); editModel.details = details; return(editModel); }
public void EditProject(ProjectEditModel projectEditModel) { using (var _uow = _unitOfWorkFactory.Create()) { var Project = Mapper.Map <Project>(projectEditModel); _uow._Projects.Update(Project); } }
public async Task Edit_POST_InvalidModel() { // arrange var model = new ProjectEditModel(); // act var result = await SystemUnderTest.Edit(model); // assert AssertInputErrorMessagesOfView(result, model); }
public static ProjectEditModel GetOrganizationOneProjectOneEditModel() { var model = new ProjectEditModel(); model.OrganizationUid = OrganizationOneUid; model.ProjectUid = OrganizationOneProjectOneUid; model.Name = OrganizationOneProjectOneName; model.Url = HttpsUrl; return(model); }
public static ProjectEditModel MapProjectEditModel(ProjectDto dto) { var model = new ProjectEditModel(); model.OrganizationUid = dto.OrganizationUid; model.ProjectUid = dto.Uid; model.Name = dto.Name; model.Description = dto.Description; model.Url = dto.Url; model.SetInputModelValues(); return(model); }
public ActionResult Edit(int id) { var projectId = id; var project = projectRepo.GetById(projectId); var pe = new ProjectEditModel { Project = project, AllactiveEmployees = employeeRepo.GetAllActive().ToList(), Customer = customerRepo.GetById(project.CustomerId), ProjectMembers = projectMemberRepo.GetForProject(projectId).ToList() }; return(View(pe)); }
public IActionResult Create(ProjectEditModel model) { if (ModelState.IsValid) { var newProject = new Project(); newProject.Name = model.Name; newProject = _projectData.Add(newProject); return(RedirectToAction(nameof(Details), new { id = newProject.Id })); } else { return(View()); } }
public ActionResult Create(int customerId) { var pe = new ProjectEditModel { Project = new Project { CustomerId = customerId, IsActive = true, IsBillable = true, ProjectType = ProjectType.HourlyBilled }, AllactiveEmployees = employeeRepo.GetAllActive().ToList(), Customer = customerRepo.GetById(customerId), }; return(View(pe)); }
public IActionResult AdminConsole(ProjectEditModel model) { var newProject = new Project(); newProject.Title = model.Title; newProject.ShortDescription = model.ShortDescription; newProject.FullDetails = model.FullDetails; newProject.ProgressStatus = model.ProgressStatus; newProject.WorkorSideProject = model.WorkorSideProject; newProject.Size = model.Size; newProject.ImgURI = model.ImgURI; newProject.GithubLink = model.GithubLink; _projectData.Add(newProject); return(View("AddSuccess", newProject)); }
public HttpResponseMessage EditProject( [FromBody] ProjectEditModel model, [FromUri] string sessionKey) { var responseMsg = this.PerformOperationAndHandleExceptions(() => { this.ValidateProjectName(model.Name); this.ValidateProjectDescription(model.Description); this.ValidateProjectUrl(model.Url); var user = this.GetUserBySessionKey(sessionKey); var project = this.db.Projects.GetById(model.Id); project.Description = model.Description; project.Name = model.Name; project.Url = model.Url; project.TeamMembers.Clear(); project.TeamMembers.Add(user); foreach (int userId in model.MembersIds) { var member = this.db.Users.GetById(userId); if (member == null) { throw new ArgumentException( string.Format("A user with id={0} does not exist", userId)); } project.TeamMembers.Add(member); } this.db.Projects.Update(project); this.db.SaveChanges(); var returnData = new ProjectModel() { Id = project.Id, Name = project.Name }; var response = this.Request.CreateResponse(HttpStatusCode.Created, returnData); return(response); }); return(responseMsg); }
public ProjectEditModel RenderEditProject(IdentityProject identity) { var editModel = new ProjectEditModel(); editModel.Code = identity.Code; editModel.ProjectCategoryId = identity.ProjectCategoryId; editModel.CompanyId = identity.CompanyId; editModel.ProjectCategorys = CommonHelpers.GetListProjectCatefory(); editModel.Companys = CommonHelpers.GetListCompany(); editModel.Name = identity.Name; editModel.ShortDescription = identity.ShortDescription; editModel.Detail = identity.Detail; editModel.BeginDate = identity.BeginDate; editModel.FinishDate = identity.FinishDate; editModel.Status = identity.Status; return(editModel); }
public IdentityProject ExtractEditFormData(ProjectEditModel formData) { var myIdentity = new IdentityProject(); myIdentity.Id = formData.Id; myIdentity.Code = formData.Code; myIdentity.ProjectCategoryId = formData.ProjectCategoryId; myIdentity.CompanyId = formData.CompanyId; myIdentity.Name = formData.Name; myIdentity.ShortDescription = formData.ShortDescription; myIdentity.Detail = formData.Detail; //myIdentity.BeginDate = Convert.ToDateTime(formData.BeginDate); //myIdentity.FinishDate = Convert.ToDateTime(formData.FinishDate); myIdentity.BeginDate = formData.BeginDate; myIdentity.FinishDate = formData.FinishDate; myIdentity.Status = formData.Status; return(myIdentity); }
private void SaveEditModel(ProjectEditModel model) { var project = model.Project; projectRepo.Save(project); var oldProjectMembers = projectMemberRepo.GetForProject(project.Id); foreach (var oldMember in oldProjectMembers) { if (model.ProjectMembers.All(p => p.Id != oldMember.Id)) { projectMemberRepo.Delete(oldMember); } } foreach (var newMember in model.ProjectMembers.Where(pm => pm.EmployeeId > 0)) { projectMemberRepo.Save(newMember); } }
public async Task <IActionResult> ProjectEdit(int?id) { if (id == null) { return(NotFound()); } var projekt = await _s16693context.Projekt.FindAsync(id); if (projekt == null) { return(NotFound()); } var zp = await _s16693context.ZespolProjekt.FirstOrDefaultAsync(x => x.IdProjekt == projekt.IdProjekt && x.DataWypisaniaZespolu == null); var pp = await _s16693context.ProjektPakiet.FirstOrDefaultAsync(x => x.IdProjekt == projekt.IdProjekt && x.DataZakonczeniaWspolpracy == null); var zespol = await _s16693context.Zespol.FirstOrDefaultAsync(x => x.IdZespol == zp.IdZespol); var pakiet = await _s16693context.Pakiet.FirstOrDefaultAsync(x => x.IdPakiet == pp.IdPakiet); var IdZespol = zespol.IdZespol; var IdPakiet = pakiet.IdPakiet; var firmy = from e in _s16693context.Firma select e; var zespoly = from e in _s16693context.Zespol select e; var pakiety = from e in _s16693context.Pakiet select e; var pEM = new ProjectEditModel { projekt = projekt, zespol = zespol, pakiet = pakiet, firmas = await firmy.ToListAsync(), zespols = await zespoly.ToListAsync(), pakiets = await pakiety.ToListAsync(), IdZespol = (int)IdZespol, IdPakiet = (int)IdPakiet }; return(View(pEM)); }
public async Task <IActionResult> Edit(ProjectEditModel model) { if (model.IsNotValid()) { model.SetInputModelValues(); return(View(model)); } var request = new ProjectEditRequest(CurrentUser.Id, model.OrganizationUid, model.ProjectUid, model.Name, model.Url, model.Description); var response = await _projectService.EditProject(request); if (response.Status.IsNotSuccess) { model.MapMessages(response); return(View(model)); } CurrentUser.IsActionSucceed = true; return(Redirect($"/Project/Detail/{ model.ProjectUid}")); }
public ActionResult Edit([Bind(Include = "ProjectId,ProjectName,ProjectDescription,ProjectDeadline")] ProjectEditModel project) { if (!ModelState.IsValid) { return(View(project)); } var projectEntity = db.Project.FirstOrDefault(x => x.ProjectId == project.ProjectId); if (projectEntity == null) { return(HttpNotFound()); } projectEntity.ProjectName = project.ProjectName; projectEntity.ProjectDeadline = project.ProjectDeadline; projectEntity.ProjectDescription = project.ProjectDescription; db.Entry(projectEntity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ProjectViewModel SaveProjectEditModelToDb(ProjectEditModel directoryEditModel) { Project _directoryDbModel; if (directoryEditModel.Id != 0) { _directoryDbModel = _dataManager.Projects.GetProjectById(directoryEditModel.Id); } else { _directoryDbModel = new Project(); } _directoryDbModel.Name = directoryEditModel.Name; _directoryDbModel.NameExeCompany = directoryEditModel.NameExeCompany; _directoryDbModel.InformationProjectManager = directoryEditModel.InformationProjectManager; _directoryDbModel.DataExeProject = directoryEditModel.DataExeProject; _directoryDbModel.DatesProject = directoryEditModel.DatesProject; _directoryDbModel.ProjectPriority = directoryEditModel.ProjectPriority; _dataManager.Projects.SaveProject(_directoryDbModel); return(ProjectDBToViewModelById(_directoryDbModel.Id)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var project = db.Project.Find(id); if (project == null) { return(HttpNotFound()); } var projectEditModel = new ProjectEditModel { ProjectId = project.ProjectId, ProjectDeadline = project.ProjectDeadline, ProjectName = project.ProjectName, ProjectDescription = project.ProjectDescription }; return(View(projectEditModel)); }
public async Task <IActionResult> UpdateProject(ProjectEditModel model) { if (ModelState.IsValid) { try { // Get the project entity var recProject = await _context.Projects.FirstOrDefaultAsync(q => q.ProjectId == model.ProjectId); var record = await _context.Projects.FirstOrDefaultAsync(q => q.ProjectId != model.ProjectId && q.Slug == model.Slug); if (record == null) { // Update unmapped properties recProject.Name = model.Name; recProject.Slug = model.Slug; recProject.Description = model.Description; recProject.Image = model.Image; recProject.Status = model.Status; recProject.DateModified = DateTime.UtcNow; // Update _context.Projects.Update(recProject); await _context.SaveChangesAsync(); return(RedirectToAction("Projects", "Dashboard")); } ModelState.AddModelError("slug", "Slug must be unique."); } catch { ModelState.AddModelError("", "An error occurred while updating the project."); } } return(View("ProjectRecord", model)); }
public ProjectEditModel GetProjectEditModel(int projectid = 0) { if (projectid != 0) { var _dirDB = _dataManager.Projects.GetProjectById(projectid); var _dirEditModel = new ProjectEditModel() { Id = _dirDB.Id, Name = _dirDB.Name, NameExeCompany = _dirDB.NameExeCompany, InformationProjectManager = _dirDB.InformationProjectManager, DataExeProject = _dirDB.DataExeProject, DatesProject = _dirDB.DatesProject, ProjectPriority = _dirDB.ProjectPriority }; return(_dirEditModel); } else { return(new ProjectEditModel() { }); } }
private bool SaveProject(ProjectEditModel model) { return(false); }
public IActionResult SaveProject(ProjectEditModel model) { _servicesmanager.Projects.SaveProjectEditModelToDb(model); return(RedirectToAction("PageEditor", "Page", new { pageId = model.Id, pageType = PageType.Project })); }
public Task <HttpResponseMessage> UpdateProject(ProjectEditModel model, TokenModel token) { TokenClient.RefreshToken(_client, token); return(_client.PostAsJsonAsync(_routePrefix + "/Update", model)); }
public async Task <IActionResult> Edit(ProjectEditModel projectEditModel) { _projectService.EditProject(projectEditModel); return(RedirectToAction("Details", new { Id = projectEditModel.Id })); }
public async Task <IActionResult> ProjectEdit(ProjectEditModel pEM) { if (ModelState.IsValid) { _s16693context.Update(pEM.projekt); var oldZP = await _s16693context.ZespolProjekt .Where(x => x.IdZespol == pEM.IdZespol && x.IdProjekt == pEM.projekt.IdProjekt && x.DataWypisaniaZespolu == null) .FirstOrDefaultAsync(); var oldPP = await _s16693context.ProjektPakiet .Where(x => x.IdPakiet == pEM.IdPakiet && x.IdProjekt == pEM.projekt.IdProjekt && x.DataZakonczeniaWspolpracy == null) .FirstOrDefaultAsync(); if (oldZP.IdZespol != pEM.zespol.IdZespol) { oldZP.DataWypisaniaZespolu = DateTime.Now; _s16693context.Update(oldZP); var newZP = new ZespolProjekt() { IdProjekt = pEM.projekt.IdProjekt, IdZespol = (int)pEM.zespol.IdZespol, DataPrzypisaniaZespolu = DateTime.Now }; _s16693context.Add(newZP); await _s16693context.SaveChangesAsync(); } if (oldPP.IdPakiet != pEM.pakiet.IdPakiet) { oldPP.DataZakonczeniaWspolpracy = DateTime.Now; _s16693context.Update(oldPP); var newPP = new ProjektPakiet() { IdProjekt = pEM.projekt.IdProjekt, IdPakiet = (int)pEM.pakiet.IdPakiet, DataRozpoczeciaWspolpracy = DateTime.Now }; _s16693context.Add(newPP); await _s16693context.SaveChangesAsync(); } await _s16693context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else if (!ModelState.IsValid) { var firmy = from e in _s16693context.Firma select e; var zespoly = from e in _s16693context.Zespol select e; var pakiety = from e in _s16693context.Pakiet select e; var newPEM = new ProjectEditModel { projekt = pEM.projekt, zespol = pEM.zespol, pakiet = pEM.pakiet, firmas = await firmy.ToListAsync(), zespols = await zespoly.ToListAsync(), pakiets = await pakiety.ToListAsync(), IdZespol = (int)pEM.IdZespol, IdPakiet = (int)pEM.IdPakiet }; return(View("ProjectEdit", newPEM)); } return(View(pEM)); }