public ResponsResult DelAdPic(AdManagerViewSearch model) { ResponsResult result = new ResponsResult(); Advertising adPic = new Advertising(); adPic.Id = model.Id; this.Delete(adPic, true); result.Message = "删除成功"; return(result); }
public ResponsResult AdPicAdd_Updata(AdManagerViewSearch model) { ResponsResult result = new ResponsResult(); Advertising adPic; if (!string.IsNullOrEmpty(model.Id)) { adPic = this.First <Advertising>(t => t.Id != model.Id && t.AdName == model.AdName && t.AdLocation == (int)model.AdLocation); } else { adPic = this.First <Advertising>(t => t.AdName == model.AdName && t.AdLocation == (int)model.AdLocation); } if (adPic != null) { return(result.SetStatus(ErrorCode.NotFound, "广告位已经存在!")); } else { if (string.IsNullOrEmpty(model.Id)) { adPic = new Advertising(); adPic = model.GetJson().GetModel <Advertising>(); adPic.AdDesc = model.AdDesc; adPic.IsEnable = true;//添加默认启用 } else { adPic = this.First <Advertising>(t => t.Id == model.Id); adPic.AdLocation = (int)model.AdLocation; adPic.AdName = model.AdName; adPic.AdPic = model.AdPic; adPic.BeginTime = model.BeginTime; adPic.EndTime = model.EndTime; adPic.AdDesc = model.AdDesc; adPic.AdLink = model.AdLink; adPic.IsEnable = model.IsEnable; } } if (!string.IsNullOrEmpty(model.Id)) { this.Update(adPic, true); } else { adPic.Id = Guid.NewGuid().ToString("N"); this.Add(adPic, true); } return(result); }
public ResponsResult AdPicAddUpdata([FromBody] AdManagerViewSearch model) { if (model == null) { return(new ResponsResult().SetStatus(ErrorCode.CannotEmpty)); } if (!string.IsNullOrEmpty(model.AdPic) && model.AdPic.Length > 1000) { DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var fileName = (long)((DateTime.Now.AddHours(-8) - Jan1st1970).TotalMilliseconds); model.AdPic = ImageHandler.SaveBase64Image(model.AdPic, $"{fileName}.png", TB.AspNetCore.Application.Services.SystemSettingService.SystemSetting.AdImagePath); } return(_commonService.AdPicAdd_Updata(model)); }
public ResponsResult IsEnableAdPic(AdManagerViewSearch model) { ResponsResult result = new ResponsResult(); var query = base.Where <Advertising>(s => s.Id == model.Id).FirstOrDefault(); if (query == null) { result.Message = "操作失败!"; return(result); } query.IsEnable = model.IsEnable;//跟新赋值 base.Update(query, true); result.Message = "操作成功!"; return(result); }
public ResponsResult AdManagerList(AdManagerViewSearch model) { ResponsResult result = new ResponsResult(); var query = base.Query <Advertising>(); if (!string.IsNullOrEmpty(model.AdName)) { query = query.Where(t => t.AdName == model.AdName); } if ((int)model.AdLocation > 0) { query = query.Where(t => t.AdLocation == (int)model.AdLocation); } List <AdManagerViewSearch> _list = new List <AdManagerViewSearch>(); query.OrderByDescending(t => t.Id).Pages(model.PageIndex, model.PageSize, out int count).Select(t => new { t.Id, t.AdLocation, t.AdName, t.AdPic, t.BeginTime, t.EndTime, t.IsEnable, t.AdLink }).ToList().ForEach(t => { _list.Add( new AdManagerViewSearch { Id = t.Id, AdName = t.AdName, BeginTime = t.BeginTime, EndTime = t.EndTime, AdPic = t.AdPic, AdLocationName = JsonExtensions.GetString((AdLocation)t.AdLocation), IsEnable = (bool)t.IsEnable,//查询是几就是几 }); } ); result.Data = _list; result.RecordCount = count; return(result); }
public ResponsResult IsEnableAdPic([FromBody] AdManagerViewSearch model) { return(_commonService.IsEnableAdPic(model)); }
public ResponsResult AdManagerList([FromBody] AdManagerViewSearch model) { return(_commonService.AdManagerList(model)); }