Esempio n. 1
0
        public PublicityContent AddInfo(CreatePublicityContentInput input)
        {
            string guid = Guid.NewGuid().ToString();

            var content = new PublicityContent()
            {
                PublicityName       = input.PublicityName.Trim(),
                PublicityCategoryID = input.PublicityCategoryID,
                NavType             = input.NavType,
                NavUrl      = input.NavUrl.Trim(),
                PublishTime = input.PublishTime,
                PublishType = input.PublishType,
                ExpiredTime = input.ExpiredTime,
                ExpiredType = input.ExpiredType,
                ShowType    = input.ShowType,
                OrderID     = input.OrderID,
                Remark      = input.Remark,
                AttachGuid  = guid,
                CreateUser  = input.CreateUser,
                CreateTime  = DateTime.Now,
                CreateIP    = IPHelper.GetIPAddress
            };

            db.PublicityContents.Add(content);

            if (input.PublicityTypesID == 1)
            {
                if (input.Attach != null)
                {
                    db.ArticleAttaches.Add(new ArticleAttach()
                    {
                        HashValue     = input.Attach.HashValue,
                        ArticleGuid   = guid,
                        AttachName    = input.Attach.AttachName,
                        AttachNewName = input.Attach.AttachNewName,
                        AttachUrl     = input.Attach.AttachUrl,
                        AttachFormat  = input.Attach.AttachFormat,
                        AttachIndex   = 1,
                        AttachBytes   = input.Attach.AttachBytes,
                        AttachType    = input.Attach.AttachType,
                        ModuleType    = (int)AttachTypesEnum.宣传图片,
                        CreateTime    = DateTime.Now,
                        CreateUser    = input.CreateUser,
                        CreateIP      = IPHelper.GetIPAddress
                    });
                }
            }
            return(db.SaveChanges() > 0 ? content : null);
        }
Esempio n. 2
0
        public ResponseInfoModel AddcontentInfo([FromBody] CreatePublicityContentInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                CheckModelState();

                var entity = _PublicityContentService.AddInfo(input);
                if (entity == null)
                {
                    json.Success = 0;
                    json.Result  = LocalizationConst.InsertFail;
                }
                else
                {
                    _logService.Insert(new Log()
                    {
                        ActionContent = LocalizationConst.Insert,
                        SourceType    = _moduleName,
                        SourceID      = entity.ID,
                        LogTime       = DateTime.Now,
                        LogUserID     = input.CreateUser,
                        LogIPAddress  = IPHelper.GetIPAddress,
                    });
                }
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/publicity/addpositionInfo", LocalizationConst.InsertFail);
            }
            return(json);
        }