public ReturnValueModel AddOrUpdateBannerInfoItem(BannerInfoItem dto, WorkUser workUser) { ReturnValueModel rvm = new ReturnValueModel(); BannerInfoItem bannerInfoItem = null; bannerInfoItem = _rep.FirstOrDefault <BannerInfoItem>(o => o.Id == dto.Id && o.IsDeleted == 0); if (bannerInfoItem == null) { bannerInfoItem = new BannerInfoItem() { Id = Guid.NewGuid().ToString(), BannerInfoId = dto.BannerInfoId, Title = dto.Title, Describe = dto.Describe, Type = dto.Type, ShowPlace = dto.ShowPlace, Src = dto.Src, Sort = dto.Sort, CreateTime = DateTime.Now, CreateUser = workUser.User.Id, }; _rep.Insert(bannerInfoItem); } else { bannerInfoItem.BannerInfoId = dto.BannerInfoId; bannerInfoItem.Title = dto.Title; bannerInfoItem.Describe = dto.Describe; bannerInfoItem.Type = dto.Type; bannerInfoItem.ShowPlace = dto.ShowPlace; bannerInfoItem.Src = dto.Src; bannerInfoItem.Sort = dto.Sort; bannerInfoItem.UpdateTime = DateTime.UtcNow.AddHours(8); bannerInfoItem.UpdateUser = workUser.User.Id; _rep.Update(bannerInfoItem); } _rep.SaveChanges(); rvm.Msg = "success"; rvm.Success = true; rvm.Result = bannerInfoItem; return(rvm); }
public ReturnValueModel DeleteBannerInfoItem(BannerInfoItem dto, WorkUser workUser) { ReturnValueModel rvm = new ReturnValueModel(); if (string.IsNullOrEmpty(dto?.Id)) { rvm.Success = false; rvm.Msg = "The parameter 'Id' is required."; return(rvm); } var bannerInfoItem = _rep.FirstOrDefault <BannerInfoItem>(o => o.Id == dto.Id && o.IsDeleted == 0); bannerInfoItem.IsDeleted = 1; bannerInfoItem.UpdateTime = DateTime.UtcNow.AddHours(8); bannerInfoItem.UpdateUser = workUser.User.Id; _rep.Update(bannerInfoItem); _rep.SaveChanges(); rvm.Success = true; rvm.Msg = "success"; return(rvm); }
public IHttpActionResult DeleteBannerInfoItem(BannerInfoItem dto) { var ret = _bannerInfoService.DeleteBannerInfoItem(dto, WorkUser); return(Ok(ret)); }