Exemplo n.º 1
0
        public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data = new DTO.DevRequest();
            data.Data.DevRequestAssignments = new List <DTO.DevRequestAssignment>();
            data.Data.DevRequestHistories   = new List <DTO.DevRequestHistory>();
            data.Data.DevRequestFiles       = new List <DTO.DevRequestFile>();

            data.HistoryData = new DTO.DevRequestHistory();
            data.HistoryData.DevRequestCommentAttachedFiles = new List <DTO.DevRequestCommentAttachedFile>();

            data.DevRequestPriorities = new List <Support.DTO.DevRequestPriority>();
            data.DevRequestProjects   = new List <Support.DTO.DevRequestProject>();
            data.DevRequestStatuses   = new List <Support.DTO.DevRequestStatus>();
            data.DevRequestTypes      = new List <Support.DTO.DevRequestType>();
            data.DevRequestPersons    = new List <DTO.DevRequestPerson>();
            data.Requesters           = new List <DTO.Requester>();

            //try to get data
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        data.Data = converter.DB2DTO_DevRequest(context.DevRequestMng_DevRequest_View
                                                                .Include("DevRequestMng_DevRequestAssignment_View")
                                                                .Include("DevRequestMng_DevRequestHistory_View")
                                                                .Include("DevRequestMng_DevRequestHistory_View.DevRequestMng_DevRequestCommentAttachedFile_View")
                                                                .Include("DevRequestMng_DevRequestFile_View")
                                                                .FirstOrDefault(o => o.DevRequestID == id));
                    }

                    data.DevRequestPriorities = supportFactory.GetDevRequestPriority().ToList();
                    data.DevRequestProjects   = supportFactory.GetDevRequestProject().ToList();
                    data.DevRequestTypes      = supportFactory.GetDevRequestType().ToList();
                    data.DevRequestStatuses   = supportFactory.GetDevRequestStatus().ToList();
                    data.DevRequestPersons    = converter.DB2DTO_DevRequestPersonList(context.DevRequestMng_DevRequestPerson_View.ToList());
                    data.Requesters           = converter.DB2DTO_RequesterList(context.DevRequestMng_Requester_View.ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }