示例#1
0
 public void DeleteRequest(RequestDTO request)
 {
     if (request == null)
     {
         throw new Exception("申请不能为空");
     }
     Request pesistRequest = _requestRepository.Get(request.Id);
     if (pesistRequest == null)
     {
         throw new Exception("找不到需要删除的申请");
     }
     _requestRepository.Remove(pesistRequest);
 }
示例#2
0
 public void InsertRequest(RequestDTO request)
 {
     if (request == null)
     {
         throw new Exception("申请不能为空");
     }
     //新申请
     Request newRequest = RequestFactory.CreateRequest(request.SubmitDate, request.Title,
         request.CaacDocNumber, request.Status, request.LogWriter, request.CaacDocumentName,
         request.CaacDocumentId, Guid.Parse("1978ADFC-A2FD-40CC-9A26-6DEDB55C335F"));
     if (request.ApprovalDocId != null) newRequest.SetApprovalDoc(request.ApprovalDocId);
     newRequest.ChangeCurrentIdentity(request.Id);
     request.ApprovalHistories.ToList().ForEach(p => newRequest.AddNewApprovalHistory(p.Id, p.SeatingCapacity,
         p.CarryingCapacity,
         p.RequestDeliverMonth, p.Note, p.RequestId,
         p.PlanAircraftId, p.ImportCategoryId, p.RequestDeliverAnnualId,
         Guid.Parse("1978ADFC-A2FD-40CC-9A26-6DEDB55C335F")));
     //string log = "创建申请" + request.Title + ",包含" + request.ApprovalHistories.Count + "条申请明细";
     //newRequest.SetNote(log);
     _requestRepository.Add(newRequest);
 }
示例#3
0
        public void ModifyRequest(RequestDTO request)
        {
            if (request == null)
            {
                throw new Exception("申请不能为空");
            }
            Request pesistRequest = _requestRepository.Get(request.Id);
            if (pesistRequest == null)
            {
                throw new Exception("找不到需要更新的申请");
            }
            //判断,如果两字段不相等,则更新
            if (pesistRequest.SubmitDate != request.SubmitDate)
            {
                pesistRequest.SetSubmitDate(request.SubmitDate);
            }
            if (pesistRequest.Title != request.Title)
            {
                pesistRequest.SetTitle(request.Title);
            }
            if (pesistRequest.CaacDocNumber != request.CaacDocNumber)
            {
                pesistRequest.SetCaacDocNumber(request.CaacDocNumber);
            }
            if (pesistRequest.Status != (RequestStatus) request.Status)
            {
                pesistRequest.SetRequestStatus((RequestStatus) request.Status);
            }
            if (!string.IsNullOrWhiteSpace(request.LogWriter))
            {
                pesistRequest.SetNote(request.LogWriter);
            }
            if (pesistRequest.CaacDocumentId != request.CaacDocumentId)
            {
                pesistRequest.SetCaacDocument(request.CaacDocumentId, request.CaacDocumentName);
            }
            if (pesistRequest.ApprovalDocId != request.ApprovalDocId)
            {
                pesistRequest.SetApprovalDoc(request.ApprovalDocId);
            }
            DataHelper.DetailHandle(request.ApprovalHistories.ToArray(), pesistRequest.ApprovalHistories.ToArray(),
                c => c.Id, c => c.Id, c => InsertApprovalHistory(pesistRequest, c), ModifyApprovalHistory,
                DeleteApprovalHistory);

            //DataHelper.DetailHandle(request.ApprovalHistories.ToArray(), pesistRequest.ApprovalHistories.ToArray(),
            //    c => c.Id, c => c.Id, c => InsertLog(pesistRequest, c), (c, p) => ModifyLog(pesistRequest, c),
            //    c => DeleteLog(pesistRequest, c));

            _requestRepository.Modify(pesistRequest);
        }