コード例 #1
0
        public ActionResult Edit(int Id)
        {
            Advertisings adv = new Advertisings();

            adv.Id     = -1;
            adv.Status = true;
            if (Id > 0)
            {
                adv = FiiiPayDB.AdvertisingDb.GetById(Id);
            }
            adv.StartDate = adv.StartDate.ToLocalTime();
            adv.EndDate   = adv.EndDate.ToLocalTime();
            var statusList = new List <SelectListItem>();

            statusList.Add(new SelectListItem()
            {
                Text = "Enable", Value = "True"
            });
            statusList.Add(new SelectListItem()
            {
                Text = "Disable", Value = "False"
            });
            ViewBag.StatusList = statusList;

            var linkTypeList = new List <SelectListItem>();

            linkTypeList.AddRange(EnumHelper.EnumToList <LinkType>().Select(t => new SelectListItem()
            {
                Text = t.EnumName, Value = t.EnumValue.ToString()
            }));
            ViewBag.LinkTypeList = linkTypeList;
            return(View(adv));
        }
コード例 #2
0
        public SaveResult Update(Advertisings adv, int userId, string userName)
        {
            Advertisings oldAdv = FiiiPayDB.AdvertisingDb.GetById(adv.Id);

            if (adv.PictureEn != Guid.Empty)
            {
                oldAdv.PictureEn = adv.PictureEn;
            }
            if (adv.PictureZh != Guid.Empty)
            {
                oldAdv.PictureZh = adv.PictureZh;
            }
            oldAdv.LinkType  = adv.LinkType;
            oldAdv.Link      = adv.Link;
            oldAdv.Title     = adv.Title;
            oldAdv.Status    = adv.Status;
            oldAdv.StartDate = adv.StartDate;
            oldAdv.EndDate   = adv.EndDate;
            oldAdv.Version   = oldAdv.Version + 1;

            // Create ActionLog
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = userId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(CryptocurrenciesBLL).FullName + ".Update";
            actionLog.Username   = userName;
            actionLog.LogContent = "Update Advertisings " + adv.Id;
            ActionLogBLL ab = new ActionLogBLL();

            ab.Create(actionLog);

            return(new SaveResult(FiiiPayDB.AdvertisingDb.Update(oldAdv)));
        }
コード例 #3
0
        public SaveResult <int> Create(Advertisings adv, int userId, string userName)
        {
            adv.Version    = 1;
            adv.CreateTime = DateTime.Now;
            // Create ActionLog
            ActionLog actionLog = new ActionLog();

            actionLog.IPAddress  = GetClientIPAddress();
            actionLog.AccountId  = userId;
            actionLog.CreateTime = DateTime.UtcNow;
            actionLog.ModuleCode = typeof(CryptocurrenciesBLL).FullName + ".Create";
            actionLog.Username   = userName;
            actionLog.LogContent = "Create Advertisings " + adv.Id;
            ActionLogBLL ab = new ActionLogBLL();

            ab.Create(actionLog);
            return(new SaveResult <int>(true, FiiiPayDB.AdvertisingDb.InsertReturnIdentity(adv)));
        }
コード例 #4
0
        public ActionResult Save(Advertisings adv)
        {
            adv.StartDate = adv.StartDate.ToUniversalTime();
            adv.EndDate   = adv.EndDate.ToUniversalTime();
            SaveResult result       = new SaveResult();
            var        linkTypeList = new List <SelectListItem>();

            linkTypeList.AddRange(EnumHelper.EnumToList <LinkType>().Select(t => new SelectListItem()
            {
                Text = t.EnumName, Value = t.EnumValue.ToString()
            }));
            ViewBag.LinkTypeList = linkTypeList;

            var statusList = new List <SelectListItem>();

            statusList.Add(new SelectListItem()
            {
                Text = "Enable", Value = "True"
            });
            statusList.Add(new SelectListItem()
            {
                Text = "Disable", Value = "False"
            });
            ViewBag.StatusList = statusList;

            if (string.IsNullOrWhiteSpace(adv.Title) || string.IsNullOrWhiteSpace(adv.Link))
            {
                return(View("Edit", adv));
            }
            //上传图片
            HttpPostedFileBase EnFile = Request.Files["PictureEn"];

            if (EnFile.ContentLength != 0)
            {
                adv.PictureEn = new Guid(new Utils.FileUploader().UpImageToCDN(EnFile));
            }
            HttpPostedFileBase ZhFile = Request.Files["PictureZh"];

            if (ZhFile.ContentLength != 0)
            {
                adv.PictureZh = new Guid(new Utils.FileUploader().UpImageToCDN(ZhFile));
            }
            if (adv.Id > 0)//编辑
            {
                SaveEdit(adv);
                Advertisings oldAdv = FiiiPayDB.AdvertisingDb.GetById(adv.Id);

                return(View("Edit", oldAdv));
            }
            else//新增
            {
                if (ZhFile.ContentLength == 0)
                {
                    return(View("Edit", adv));
                }
                if (EnFile.ContentLength == 0)
                {
                    return(View("Edit", adv));
                }
                int          newId  = SaveCreate(adv).Data;
                Advertisings newAdv = FiiiPayDB.AdvertisingDb.GetById(newId);
                return(View("Edit", newAdv));
            }
        }
コード例 #5
0
        private SaveResult SaveEdit(Advertisings adv)
        {
            AdvertisingsBLL ab = new AdvertisingsBLL();

            return(ab.Update(adv, UserId, UserName));
        }
コード例 #6
0
        private SaveResult <int> SaveCreate(Advertisings adv)
        {
            AdvertisingsBLL ab = new AdvertisingsBLL();

            return(ab.Create(adv, UserId, UserName));
        }