Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static ApplyVdto ToVDTO(this SubmitApplyViewModel model)
        {
            var b = new ApplyVdto()
            {
                BaseInfoId    = model.BaseId ?? Guid.Empty,
                RequestInfoId = model.RequestId ?? Guid.Empty,
                IsPlan        = model.IsPlan,
                EntityType    = model.EntityType
            };

            return(b);
        }
        public Apply Submit(ApplyVdto model)
        {
            if (model == null)
            {
                throw new ActionStatusMessageException(ActionStatusMessage.ApplyMessage.Default);
            }
            var apply = new Apply()
            {
                BaseInfo    = context.ApplyBaseInfos.Find(model.BaseInfoId),
                Create      = DateTime.Now,
                RequestInfo = context.ApplyRequests.Find(model.RequestInfoId),
                Status      = AuditStatus.NotSave,
                MainStatus  = model.IsPlan ? MainStatus.IsPlan : MainStatus.Normal
            };

            if (apply.RequestInfo == null)
            {
                throw new ActionStatusMessageException(ActionStatusMessage.ApplyMessage.Operation.Submit.NoRequestInfo);
            }
            if (apply.BaseInfo == null)
            {
                throw new ActionStatusMessageException(ActionStatusMessage.ApplyMessage.Operation.Submit.NoBaseInfo);
            }
            var company = apply.BaseInfo?.Company;

            if (company == null)
            {
                throw new ActionStatusMessageException(ActionStatusMessage.CompanyMessage.NotExist);
            }
            AuditStreamModel auditItem = apply.ToModel();

            auditStreamServices.InitAuditStream(ref auditItem, model.EntityType, apply.BaseInfo?.From);
            apply = auditItem.ToModel(apply);
            apply = Create(apply);              // 创建成功,记录本次创建详情
            return(apply);
        }