static void UpdateIssueByadmin() { IIssueHistoryDTO issueHDTO = (IIssueHistoryDTO)DTOFactory.Instance.Create(DTOType.IssueHistoryDTO); int issueId; System.Console.WriteLine("Issue Id : "); int.TryParse(System.Console.ReadLine(), out issueId); issueHDTO.IssueId = issueId; System.Console.WriteLine("Comments : "); issueHDTO.Comments = System.Console.ReadLine(); System.Console.WriteLine("Modified By : "); int modifiedBy; int.TryParse(System.Console.ReadLine(), out modifiedBy); issueHDTO.ModifiedBy = modifiedBy; issueHDTO.ModifiedOn = DateTime.Now; System.Console.WriteLine("AssignedTo : "); int assigned; int.TryParse(System.Console.ReadLine(), out assigned); issueHDTO.AssignedTo = assigned; System.Console.WriteLine("Status : "); int status; int.TryParse(System.Console.ReadLine(), out status); issueHDTO.Status = status; IIssueFacade issueFacade = (IIssueFacade)FacadeFactory.Instance.Create(FacadeType.IssueManagerFacade); OperationResult <IIssueHistoryDTO> issueDTO = issueFacade.UpdateIssueByAdmin(issueHDTO); if (issueDTO.IsValid()) { System.Console.WriteLine("Issue Updated. "); } }
/// <summary> /// Create a new entry in issue and issue history table /// </summary> /// <param name="issueDTO"></param> /// <returns></returns> public IIssueDTO CreateIssue(IIssueDTO issueDTO) { IIssueDTO createIssueRetVal = null; try { using (EmployeePortal2017Entities portal = new EmployeePortal2017Entities()) { using (var transScope = new TransactionScope()) { issueDTO.IsActive = true; Issue issue = new Issue(); EntityConverter.FillEntityFromDTO(issueDTO, issue); portal.Issues.Add(issue); portal.SaveChanges(); issueDTO.IssueId = issue.IssueId; IIssueHistoryDTO issueHistoryDTO = (IIssueHistoryDTO)DTOFactory.Instance.Create(DTOType.IssueHistoryDTO); issueHistoryDTO.IssueId = issue.IssueId; issueHistoryDTO.AssignedTo = null; issueHistoryDTO.Comments = null; issueHistoryDTO.ModifiedBy = issue.PostedBy; issueHistoryDTO.ModifiedOn = DateTime.Now; issueHistoryDTO.Status = (int)IssueStatus.Raised; IssueHistory issueHistory = new IssueHistory(); EntityConverter.FillEntityFromDTO(issueHistoryDTO, issueHistory); portal.IssueHistories.Add(issueHistory); portal.SaveChanges(); transScope.Complete(); createIssueRetVal = issueDTO; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message); } return(createIssueRetVal); }
public OperationResult <IIssueHistoryDTO> UpdateIssueByAdmin(IIssueHistoryDTO issueDTO) { OperationResult <IIssueHistoryDTO> retVal = null; try { EmployeePortalValidationResult validationResult = Validator <IssueHistoryValidator, IIssueHistoryDTO> .Validate(issueDTO, ValidationConstants.UpdateIssueHistory); if (!validationResult.IsValid) { retVal = OperationResult <IIssueHistoryDTO> .CreateFailureResult(validationResult); } else { IIssueDAC issueDAC = (IIssueDAC)DACFactory.Instance.Create(DACType.IssueManagerDAC); IIssueHistoryDTO resultIssueDTO = issueDAC.UpdateIssueByAdmin(issueDTO); if (resultIssueDTO != null) { retVal = OperationResult <IIssueHistoryDTO> .CreateSuccessResult(resultIssueDTO); } else { retVal = OperationResult <IIssueHistoryDTO> .CreateFailureResult("Update issue by admin Failed!"); } } } catch (DACException dacEx) { retVal = OperationResult <IIssueHistoryDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <IIssueHistoryDTO> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
/// <summary> /// This should make an insertion in the IssueHistory table against an entry in the Issue table. /// If successfully done, return the relevant IssueHistoryDTO else return null. /// </summary> /// <param name="issueHistoryDTO"></param> /// <returns></returns> public IIssueHistoryDTO UpdateIssueByAdmin(IIssueHistoryDTO issueHistoryDTO) { IIssueHistoryDTO updateIssueByAdminRetVal = null; try { using (EmployeePortal2017Entities portal = new EmployeePortal2017Entities()) { IssueHistory issueHistory = new IssueHistory(); EntityConverter.FillEntityFromDTO(issueHistoryDTO, issueHistory); portal.IssueHistories.Add(issueHistory); portal.SaveChanges(); issueHistoryDTO.IssueHistoryId = issueHistory.IssueHistoryId; updateIssueByAdminRetVal = issueHistoryDTO; } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message); } return(updateIssueByAdminRetVal); }
public OperationResult <IIssueHistoryDTO> UpdateIssueByAdmin(IIssueHistoryDTO issueHistoryDTO) { IIssueBDC issueBDC = (IIssueBDC)BDCFactory.Instance.Create(BDCType.IssueManagerBDC); return(issueBDC.UpdateIssueByAdmin(issueHistoryDTO)); }