// GET: Project/Edit/5 public ActionResult Edit(int?id) { AllocationModel empModel = new AllocationModel(); try { InitializePageData(); if (!id.HasValue) { DisplayWarningMessage("Looks like, the required data is not available with your request"); return(RedirectToAction("List")); } if (!allocationService.Exists(id.Value)) { DisplayWarningMessage($"Sorry, we couldn't find the allocation details with ID: {id.Value}"); return(RedirectToAction("List")); } ProjectAllocationDto emp = allocationService.GetByID(id.Value); empModel = Mapper.Map <ProjectAllocationDto, AllocationModel>(emp); } catch (Exception exp) { DisplayReadErrorMessage(exp); } return(View(empModel)); }
public ActionResult Edit(AllocationModel allocation) { try { InitializePageData(); if (ModelState.IsValid) { if (IsValidAllocation(allocation) == false) { return(View(allocation)); } if (allocation.AllocationEndDate <= allocation.AllocationStartDate) { DisplayWarningMessage("The End date should be greater than the Start date"); return(View(allocation)); } ProjectAllocationDto projectDto = Mapper.Map <AllocationModel, ProjectAllocationDto>(allocation); allocationService.Update(projectDto); DisplaySuccessMessage($"Project allocation details have been updated for {allocation.EmployeeName}"); return(RedirectToAction("List")); } } catch (Exception exp) { DisplayUpdateErrorMessage(exp); } return(View(allocation)); }
public ActionResult Edit(AllocationModel allocation, string filterType, string filterValue, string sortBy, string sortType, int?page) { try { InitializePageData(); if (ModelState.IsValid) { if (IsValidAllocation(allocation) == false) { return(View(allocation)); } if (allocation.AllocationEndDate <= allocation.AllocationStartDate) { DisplayWarningMessage("The End date should be greater than the Start date"); return(View(allocation)); } ProjectAllocationDto projectDto = Mapper.Map <AllocationModel, ProjectAllocationDto>(allocation); allocationService.Update(projectDto); DisplaySuccessMessage($"Project allocation details have been updated successfully."); return(RedirectToAction("List", new { filterType, filterValue, sortBy, sortType, page })); } } catch (Exception exp) { DisplayUpdateErrorMessage(exp); } return(View(allocation)); }
public void Add(ProjectAllocationDto entity) { ProjectAllocation allocation = CreateBusinessEntity(entity, true); Entities.Add(allocation); DataContext.Entry(allocation).State = EntityState.Added; DataContext.SaveChanges(); }
public void Update(ProjectAllocationDto entity) { ProjectAllocation buzEntity = Entities.FirstOrDefault(e => e.AllocationEntryID == entity.AllocationEntryID); MigrateEntity(entity, buzEntity); Entities.Add(buzEntity); DataContext.Entry(buzEntity).State = EntityState.Modified; DataContext.SaveChanges(); }
public void Delete(ProjectAllocationDto entity) { ProjectAllocation allocation = Entities.FirstOrDefault(e => e.AllocationEntryID == entity.AllocationEntryID); allocation.IsDeleted = true; allocation.UpdateTimeStamp(entity.LoggedInUserName); Entities.Add(allocation); DataContext.Entry(allocation).State = EntityState.Modified; DataContext.SaveChanges(); }
private void MigrateEntity(ProjectAllocationDto sourceEntity, ProjectAllocation targetEntity) { targetEntity.AllocationEndDate = sourceEntity.AllocationEndDate; targetEntity.AllocationStartDate = sourceEntity.AllocationStartDate; targetEntity.AllocationTypeID = sourceEntity.AllocationTypeID; targetEntity.EmployeeID = sourceEntity.EmployeeID; targetEntity.ProjectID = sourceEntity.ProjectID; targetEntity.PercentageOfAllocation = sourceEntity.PercentageOfAllocation; targetEntity.Remarks = sourceEntity.Remarks; targetEntity.UpdateTimeStamp(sourceEntity.LoggedInUserName); }
private string GenerateAllocationFailureEmailContent(ProjectAllocationDto allocation) { string templateFilePath = ProcessorHelper.GetSettingsValue(ProcessorHelper.TEMPLATE_FOLDER_PATH) + "\\AllocationFailureEmailTemplate.html"; string emailTemplateContent = FilesHandler.GetFileContent(templateFilePath); StringBuilder emailBody = new StringBuilder(emailTemplateContent); CultureInfo ci = Thread.CurrentThread.CurrentUICulture; emailBody.Replace("__START_DATE__", $"{allocation.AllocationStartDate.Day}/{ci.DateTimeFormat.GetAbbreviatedMonthName(allocation.AllocationStartDate.Month)}/{allocation.AllocationStartDate.Year}"); emailBody.Replace("__END_DATE__", $"{allocation.AllocationEndDate.Day}/{ci.DateTimeFormat.GetAbbreviatedMonthName(allocation.AllocationEndDate.Month)}/{allocation.AllocationEndDate.Year}"); emailBody.Replace("__RESOURCE_NAME__", allocation.EmployeeName); emailBody.Replace("__PROJECT_NAME__", allocation.ProjectName); emailBody.Replace("__RESOURCE_ID__", allocation.EmployeeID.ToString()); return(emailBody.ToString()); }
private ProjectAllocation CreateBusinessEntity(ProjectAllocationDto projectDto, bool isNewEntity = false) { ProjectAllocation entity = new ProjectAllocation { AllocationEndDate = projectDto.AllocationEndDate, AllocationStartDate = projectDto.AllocationStartDate, AllocationTypeID = projectDto.AllocationTypeID, EmployeeID = projectDto.EmployeeID, ProjectID = projectDto.ProjectID, PercentageOfAllocation = projectDto.PercentageOfAllocation, AllocationEntryID = projectDto.AllocationEntryID, IsActive = projectDto.AllocationEndDate > DateTime.Now, Remarks = projectDto.Remarks, }; entity.UpdateTimeStamp(projectDto.LoggedInUserName, isNewEntity: true); return(entity); }
private void SendAllocationFailureNotification(ProjectAllocationDto allocation) { EmployeeDto emp = employeeRepo.GetByID(allocation.EmployeeID); ProjectDto proj = projectRepo.GetByID(allocation.ProjectID); EmployeeDto pm = employeeRepo.GetByID(proj.ProjectManagerID); EmployeeDto rm = emp.ReportingManagerID.HasValue ? employeeRepo.GetByID(emp.ReportingManagerID.Value) : null; StringBuilder toEmailID = new StringBuilder(); if (!string.IsNullOrEmpty(pm?.EmailID)) { toEmailID.Append(pm.EmailID); } else { toEmailID.Append(dmEmailID); } StringBuilder bccEmailIDs = new StringBuilder(); if (!string.IsNullOrEmpty(emp?.EmailID)) { bccEmailIDs.Append(emp.EmailID + ";"); } if (!string.IsNullOrEmpty(rm?.EmailID)) { bccEmailIDs.Append(rm.EmailID + ";"); } bccEmailIDs.Append(dmEmailID); string emailSubject = "Automated Resource Allocation Failure"; EmailHandler emailHandler = new EmailHandler(ownerEmailID, outlookPwd); string emailContent = GenerateAllocationFailureEmailContent(allocation); emailHandler.SendEmail(emailClientIP, toEmailID.ToString(), emailSubject, emailContent, bccEmailIDs.ToString()); }
public ActionResult Create(AllocationModel allocation) { try { InitializePageData(); if (ModelState.IsValid) { if (IsValidAllocation(allocation) == false) { return(View(allocation)); } if (allocation.AllocationEndDate <= allocation.AllocationStartDate) { DisplayWarningMessage("The End date should be greater than the Start date"); return(View(allocation)); } if (allocationService.AnyActiveAllocationInBenchProject(allocation.EmployeeID)) { DisplayWarningMessage("There is an active allocation in Bench project for this employee. Please end the allocation for that project."); return(View(allocation)); } ProjectAllocationDto projectDto = Mapper.Map <AllocationModel, ProjectAllocationDto>(allocation); allocationService.Add(projectDto); DisplaySuccessMessage($"New project allocation has been created for {allocation.EmployeeName}"); return(RedirectToAction("List")); } } catch (Exception exp) { DisplayUpdateErrorMessage(exp); } return(View(allocation)); }
private void EndAllocation(ProjectAllocationDto allocation) { }
public void Update(ProjectAllocationDto entity) { repository.Update(entity); }
public void Delete(ProjectAllocationDto entity) { repository.Delete(entity); }
public void Add(ProjectAllocationDto entity) { repository.Add(entity); }