/// <summary> /// Update the issue table (changes only in Issue table , no changes in Issue history table) /// a.Yes – return the updated IssueDTO /// b.No – return Null /// </summary> /// <param name="issueDTO"></param> /// <returns></returns> public IIssueDTO UpdateIssue(IIssueDTO issueDTO) { IIssueDTO updateIssueRetVal = null; try { using (EmployeePortal2017Entities portal = new EmployeePortal2017Entities()) { Issue issue = portal.Issues.Where(i => i.IssueId == issueDTO.IssueId).SingleOrDefault(); if (issue != null) { issueDTO.IsActive = true; EntityConverter.FillEntityFromDTO(issueDTO, issue); if (portal.SaveChanges() > 0) { updateIssueRetVal = issueDTO; } } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message); } return(updateIssueRetVal); }
static void CreateIssue() { IIssueDTO issueDTO = (IIssueDTO)DTOFactory.Instance.Create(DTOType.IssueDTO); System.Console.WriteLine("Title : "); issueDTO.Title = System.Console.ReadLine(); System.Console.WriteLine("Description : "); issueDTO.Description = System.Console.ReadLine(); System.Console.WriteLine("Posted By : "); int postedBy; int.TryParse(System.Console.ReadLine(), out postedBy); issueDTO.PostedBy = postedBy; System.Console.WriteLine("Priority : "); IssuePriority priority; Enum.TryParse <IssuePriority>(System.Console.ReadLine(), out priority); issueDTO.Priority = (int)priority; IIssueFacade issueFacade = (IIssueFacade)FacadeFactory.Instance.Create(FacadeType.IssueManagerFacade); OperationResult <IIssueDTO> issueDTORetVal = issueFacade.CreateIssue(issueDTO); if (issueDTORetVal.IsValid()) { System.Console.WriteLine("Issue Created. Id : " + issueDTORetVal.Data.IssueId); } }
public OperationResult <IIssueDTO> GetIssue(int IssueId) { OperationResult <IIssueDTO> retVal = null; try { IIssueDAC issueDAC = (IIssueDAC)DACFactory.Instance.Create(DACType.IssueManagerDAC); IIssueDTO resultIssueDTO = issueDAC.GetIssue(IssueId); if (resultIssueDTO != null) { retVal = OperationResult <IIssueDTO> .CreateSuccessResult(resultIssueDTO); } else { retVal = OperationResult <IIssueDTO> .CreateFailureResult("Get issue Failed!"); } } catch (DACException dacEx) { retVal = OperationResult <IIssueDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <IIssueDTO> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
/// <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); }
/// <summary> /// Return IssueDTO corresponding to the passed issue id. /// The IssueDTO should also contain nested inside it list of IIssueHistoryDTOs /// </summary> /// <param name="issueId"></param> /// <returns></returns> public IIssueDTO GetIssue(int issueId) { IIssueDTO issueDTO = null; try { using (EmployeePortal2017Entities portal = new EmployeePortal2017Entities()) { var issue = portal.Issues.Include("Employee") .Where(i => i.IssueId == issueId && i.IsActive) .SingleOrDefault(); if (issue != null) { issueDTO = (IIssueDTO)DTOFactory.Instance.Create(DTOType.IssueDTO); EntityConverter.FillDTOFromEntity(issue, issueDTO); issueDTO.EmployeeDTO = (IEmployeeDTO)DTOFactory.Instance.Create(DTOType.EmployeeDTO); EntityConverter.FillDTOFromEntity(issue.Employee, issueDTO.EmployeeDTO); var issueHistoryList = portal.GetIssueHistoryByIssueId(issueId).ToList(); if (issueHistoryList.Count > 0) { issueDTO.IssueHistories = new List <IComplexIssueHistoryDTO>(); IComplexIssueHistoryDTO issueHistoryDTO = null; foreach (var issueHistory in issueHistoryList) { issueHistoryDTO = (IComplexIssueHistoryDTO)DTOFactory.Instance.Create(DTOType.ComplexIssueHistoryDTO); EntityConverter.FillDTOFromComplexObject(issueHistory, issueHistoryDTO); issueDTO.IssueHistories.Add(issueHistoryDTO); } } } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message); } return(issueDTO); }
public OperationResult <IIssueDTO> UpdateIssue(IIssueDTO issueDTO) { OperationResult <IIssueDTO> retVal = null; try { EmployeePortalValidationResult validationResult = Validator <Issuevalidator, IIssueDTO> .Validate(issueDTO, ValidationConstants.UpdateIssue); if (!validationResult.IsValid) { retVal = OperationResult <IIssueDTO> .CreateFailureResult(validationResult); } else { IIssueDAC issueDAC = (IIssueDAC)DACFactory.Instance.Create(DACType.IssueManagerDAC); IIssueDTO resultIssueDTO = issueDAC.UpdateIssue(issueDTO); if (resultIssueDTO != null) { retVal = OperationResult <IIssueDTO> .CreateSuccessResult(resultIssueDTO); } else { retVal = OperationResult <IIssueDTO> .CreateFailureResult("Update issue Failed!"); } } } catch (DACException dacEx) { retVal = OperationResult <IIssueDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <IIssueDTO> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
public OperationResult <IIssueDTO> UpdateIssue(IIssueDTO issueDTO) { IIssueBDC issueBDC = (IIssueBDC)BDCFactory.Instance.Create(BDCType.IssueManagerBDC); return(issueBDC.UpdateIssue(issueDTO)); }