Example #1
0
        /// <summary>
        /// 用户消息新增编辑
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ValidateResult <CrmEntity> > AddAndEdit(UserMsgequest request)
        {
            var validateResult  = new ValidateResult <CrmEntity>();
            var reusetCrmEntity = new CrmEntity("mcs_user_msg", new Guid());

            //新增
            if (string.IsNullOrWhiteSpace(request.mcs_user_msgid))
            {
                var createEntity = new CrmExecuteEntity("mcs_user_msg", Guid.NewGuid());
                BasicAssignment(createEntity, request);
                var reuset = await _crmService.Create(createEntity);

                reusetCrmEntity.Id = createEntity.Id;
            }
            //编辑
            if (!string.IsNullOrWhiteSpace(request.mcs_user_msgid))
            {
                var updateEntity = new CrmExecuteEntity("mcs_user_msg", Guid.Parse(request.mcs_user_msgid));
                BasicAssignment(updateEntity, request);
                await _crmService.Update(updateEntity);

                reusetCrmEntity.Id = updateEntity.Id;
            }
            validateResult.Data        = reusetCrmEntity;
            validateResult.Result      = true;
            validateResult.Description = "操作成功";
            return(validateResult);
        }
Example #2
0
 /// <summary>
 /// 基础字段赋值
 /// </summary>
 /// <param name="createEntity"></param>
 /// <param name="request"></param>
 private void BasicAssignment(CrmExecuteEntity entity, UserMsgequest request)
 {
     //消息标题
     if (!string.IsNullOrWhiteSpace(request.mcs_name))
     {
         entity.Attributes["mcs_name"] = request.mcs_name;
     }
     //C端用户Id
     if (!string.IsNullOrWhiteSpace(request.mcs_user))
     {
         var useref = new CrmEntityReference("mcs_user", Guid.Parse(request.mcs_user));
         entity.Attributes["mcs_user"] = useref;
     }
     //跳转链接
     if (!string.IsNullOrWhiteSpace(request.mcs_url))
     {
         entity.Attributes["mcs_url"] = request.mcs_url;
     }
     //阅读时间
     if (request.mcs_readdate != null)
     {
         var readdate = request.mcs_readdate.Value.ToUniversalTime();
         entity.Attributes["mcs_readdate"] = readdate;
     }
     //导航图片Url
     if (!string.IsNullOrWhiteSpace(request.mcs_head_imageurl))
     {
         entity.Attributes["mcs_head_imageurl"] = request.mcs_head_imageurl;
     }
     //消息内容
     if (!string.IsNullOrWhiteSpace(request.mcs_content))
     {
         entity.Attributes["mcs_content"] = request.mcs_content;
     }
     //删除时间
     if (request.mcs_deletedate != null)
     {
         var deletedate = request.mcs_deletedate.Value.ToUniversalTime();
         entity.Attributes["mcs_deletedate"] = deletedate;
     }
     //消息类型
     if (request.mcs_type != null)
     {
         entity.Attributes["mcs_type"] = request.mcs_type;
     }
     //阅读状态
     if (request.mcs_readstatus != null)
     {
         entity.Attributes["mcs_readstatus"] = request.mcs_readstatus;
     }
     //删除状态
     if (request.mcs_deletestatus != null)
     {
         entity.Attributes["mcs_deletestatus"] = request.mcs_deletestatus;
     }
 }
Example #3
0
 public async Task <ValidateResult <CrmEntity> > AddAndEdit(UserMsgequest request)
 {
     return(await _usermsgService.AddAndEdit(request));
 }
Example #4
0
 public async Task <NewtonsoftJsonActionResult <ValidateResult <CrmEntity> > > AddAndEdit(UserMsgequest request)
 {
     return(await app.AddAndEdit(request));
 }