public IActionResult PutSeckill(int id, Seckill Seckill) { if (id != Seckill.Id) { return(BadRequest()); } try { SeckillService.Update(Seckill); } catch (DbUpdateConcurrencyException) { if (!SeckillExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public int SeckillUpdate(Seckill s) { string sql = $"update seckill set SeckillName='{s.SeckillName}',SeckillSatrt='{s.SeckillSatrt}',SeckillEnd='{s.SeckillEnd}' where SeckillId={s.SeckillId}"; int h = _db.ExecuteNonQuery(sql); return(h); }
public int SeckillAdd(Seckill s) { string sql = $"insert into seckill(SeckillName,SeckillSatrt,SeckillEnd,SeckillState) values('{s.SeckillName}','{s.SeckillSatrt}','{s.SeckillEnd}',{(s.SeckillState == true ? 1 : 0)})"; int h = _db.ExecuteNonQuery(sql); return(h); }
public IEnumerable <Seckill> GetSeckills(Seckill seckill) { IQueryable <Seckill> query = _seckillContext.Seckills; if (seckill.Id != 0) { query = query.Where(s => s.Id == seckill.Id); } if (seckill.SeckillType != 0) { query = query.Where(s => s.SeckillType == seckill.SeckillType); } if (seckill.SeckillName != null) { query = query.Where(s => s.SeckillName == seckill.SeckillName); } if (seckill.SeckillUrl != null) { query = query.Where(s => s.SeckillUrl == seckill.SeckillUrl); } if (seckill.SeckillPrice != 0) { query = query.Where(s => s.SeckillPrice == seckill.SeckillPrice); } if (seckill.SeckillStock != 0) { query = query.Where(s => s.SeckillStock == seckill.SeckillStock); } if (seckill.SeckillPercent != null) { query = query.Where(s => s.SeckillPercent == seckill.SeckillPercent); } if (seckill.TimeId != 0) { query = query.Where(s => s.TimeId == seckill.TimeId); } if (seckill.ProductId != 0) { query = query.Where(s => s.ProductId == seckill.ProductId); } if (seckill.SeckillLimit != 0) { query = query.Where(s => s.SeckillLimit == seckill.SeckillLimit); } if (seckill.SeckillDescription != null) { query = query.Where(s => s.SeckillDescription == seckill.SeckillDescription); } if (seckill.SeckillIsEnd != 0) { query = query.Where(s => s.SeckillIsEnd == seckill.SeckillIsEnd); } if (seckill.SeckillStatus != 0) { query = query.Where(s => s.SeckillStatus == seckill.SeckillStatus); } return(query); }
public ActionResult <IEnumerable <Seckill> > GetSeckills(int timeId) { Seckill seckill = new Seckill(); seckill.TimeId = timeId; var seckills = SeckillService.GetSeckills(seckill).ToList(); return(seckills); }
public ActionResult <IEnumerable <Seckill> > GetList([FromQuery] Seckill seckill) { List <Seckill> seckills = SeckillService.GetSeckills(seckill).ToList(); // 1、一个页面需要多个模型 例如:秒杀列表:Seckill product ===> 新的对象Dto // 2、保证业务模型数据安全 // 2、业务模型进行传输 // po(参数) ---- > model(业务模型数据) ---->dto(外界访问数据) // AutoMapper return(seckills); }
public void SubstrackSeckillStock(int productId, int productCount) { ///获取秒杀信息 Seckill seckill = _memoryCache.Get <Seckill>(productId); //扣减库存 seckill.SeckillStock = seckill.SeckillStock = productCount; //更新库存 _memoryCache.Set <Seckill>(productId, seckill); }
public IActionResult SetProductStock(SeckillPo seckillPo) { // 1、查询秒杀库存 Seckill seckill = SeckillService.GetSeckillByProductId(seckillPo.ProductId); // 2、判断秒杀库存是否完成 if (seckill.SeckillStock <= 0) { throw new BizException("秒杀库存完了"); } // 3、扣减秒杀库存 seckill.SeckillStock = seckill.SeckillStock - seckillPo.ProductCount; // 4、更新秒杀库存 SeckillService.Update(seckill); return(Ok("更新库存成功")); }
public IActionResult SetProductStock(SeckillPo seckillPo) { //1.查询秒杀库存 Seckill seckill = _seckillService.GetSeckillByProductId(seckillPo.ProductId); //2.判断秒杀库存是否完成 if (seckill.SeckillStock <= 0) { throw new BizException("秒杀库存完了"); } if (seckill.SeckillStock <= seckillPo.ProductCount) { throw new BizException($"秒杀库存不足{seckillPo.ProductCount}个"); } //3.扣减库存 seckill.SeckillStock -= seckillPo.ProductCount; //4.更新秒杀库存 _seckillService.Update(seckill); return(Ok("更新库存成功")); }
public IActionResult PutProductStock(SeckillPo seckillPo) { // 1、查询秒杀库存 Seckill seckill = SeckillService.GetSeckillByProductId(seckillPo.ProductId); // 2、判断秒杀库存是否完成 if (seckill.SeckillStock <= 0) { throw new BizException("秒杀库存完了"); } // 3、扣减秒杀库存 seckill.SeckillStock = seckill.SeckillStock - seckillPo.ProductCount; // 4、更新秒杀库存 SeckillService.Update(seckill); // 5、seckill 转换成为Dto对象seckill // SeckillDto seckillDto = AutoMapperHelper.AutoMapTo<SeckillDto>(seckill); return(Ok("更新库存成功")); }
public SeckillDto GetSeckill(int id) { // 1、秒杀活动 Seckill seckill = seckillsClient.GetSeckill(id); var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <Seckill, SeckillDto>(); }); IMapper mapper = configuration.CreateMapper(); SeckillDto seckillDto = mapper.Map <Seckill, SeckillDto>(seckill); // 2、查询秒杀商品信息 Product product = productClient.GetProduct(seckill.ProductId); seckillDto.ProductPrice = product.ProductPrice; seckillDto.ProductDescription = product.ProductDescription; seckillDto.ProductTitle = product.ProductTitle; seckillDto.ProductUrl = product.ProductUrl; return(seckillDto); }
public void Create(Seckill seckill) { _seckillContext.Set <Seckill>().Add(seckill); _seckillContext.SaveChanges(); }
public void Update(Seckill seckill) { throw new NotImplementedException(); }
public void Update(Seckill Seckill) { SeckillContext.Seckills.Update(Seckill); SeckillContext.SaveChanges(); }
public int GetSeckillStock(int productId) { Seckill seckill = _memoryCache.Get <Seckill>(productId); return(seckill.SeckillStock); }
public IActionResult SeckillUp(Seckill s)//秒杀修改 { int h = _bll.SeckillUpdate(s); return(Ok(new { msg = h > 0 ? "修改成功" : "修改失败" })); }
public IActionResult Add(Seckill s)//商品的添加 { int h = _bll.SeckillAdd(s); return(Ok(new { msg = h > 0 ? "添加成功" : "添加失败" })); }
public ActionResult <IEnumerable <Seckill> > GetList([FromQuery] Seckill seckill) { return(_seckillService.GetSeckills(seckill).ToList()); }
public void Delete(Seckill Seckill) { SeckillRepository.Delete(Seckill); }
public void Update(Seckill Seckill) { SeckillRepository.Update(Seckill); }
public void Delete(Seckill Seckill) { SeckillContext.Seckills.Remove(Seckill); SeckillContext.SaveChanges(); }
void ContinueAction() { // make counter list for (int j = 0; j < reportAction_.counters_.Length; ++j) { counterLst_.Add(reportAction_.counters_[j]); } /// add state for (int i = 0; i < reportAction_.stateIds_.Length; ++i) { BattleActor actor = Battle.Instance.GetActorByInstId(reportAction_.stateIds_[i].ownerId_); //如果大于1 则延迟加buff if (reportAction_.stateIds_[i].addQueue_ > 0) { //如果目标是自己 加到行动后state列表,否则加到延迟state列表 if (reportAction_.stateIds_[i].ownerId_ == m_PlayerID) { afterActionBuff.Add(reportAction_.stateIds_[i]); } else { actor.ControlEntity.lagStateList.Add(reportAction_.stateIds_[i]); } continue; } if (reportAction_.stateIds_[i].add_) { actor.ControlEntity.AddState(reportAction_.stateIds_[i]); } else { actor.ControlEntity.RemoveState((int)reportAction_.stateIds_[i].stateId_); } } /// deal self state. ExcuteState(StateInst.ExcuteType.ET_Action, (COM_ReportActionCounter counter) => { /// do action BattleActor caster = Battle.Instance.GetActorByInstId(reportAction_.casterId_); if (caster == null) { //DealAfterActionState(); return; } SkillData data = null; data = SkillData.GetData((int)reportAction_.skill_, (int)reportAction_.skillLevel_); /// extra skill if (data == null) { if (reportAction_.status_ == OrderStatus.OS_Weapon) { COM_Item inst = new COM_Item(); inst.itemId_ = (uint)reportAction_.itemId_; inst.instId_ = (uint)reportAction_.weaponInstId_; if (inst.itemId_ != 0) { Battle.Instance.GetActorByInstId(reportAction_.casterId_).wearEquip(inst); } else { Battle.Instance.GetActorByInstId(reportAction_.casterId_).demontWeapon(); } } DealAfterActionState(); return; } else { if (data._SkillType == SkillType.SKT_DefaultSecPassive || data._SkillType == SkillType.SKT_Passive) { DealAfterActionState(); return; } switch (data._Passive_type) { case PassiveType.PAT_Runaway: RunAway ra = new RunAway(); ra.Run(caster, Battle.Instance.GetActorByInstId(reportAction_.babyId_), reportAction_.status_.Equals(OrderStatus.OS_RunawayOk), (ParamData pdata) => { DealAfterActionState(); }); return; case PassiveType.PAT_Change: ChangePosition cp = new ChangePosition(); cp.ChangePos((int)reportAction_.bp0_, (int)reportAction_.bp1_, (ParamData pdata) => { DealAfterActionState(); }); return; case PassiveType.PAT_BabyInnout: BabyInnOut bio = new BabyInnOut(); bio.Excute(caster, reportAction_.status_, reportAction_.babyId_, reportAction_.baby_, DealAfterActionState); ClearState(); return; case PassiveType.PAT_SecKill: Seckill sk = new Seckill(); SkillData sdata = SkillData.GetData((int)reportAction_.skill_, (int)reportAction_.skillLevel_); if (sdata._Cast_effectID != -1) { EffectAPI.Play((EFFECT_ID)sdata._Cast_effectID, caster.ControlEntity.ActorObj, null, null, (int iVal) => { if (reportAction_.targets_ == null || reportAction_.targets_.Length == 0) { ClientLog.Instance.Log("Sec Kill has no target!"); return; } sk.Do(caster, Battle.Instance.GetActorByIdx((int)reportAction_.targets_[0].position_), DealAfterActionState); }); } else { if (reportAction_.targets_ == null || reportAction_.targets_.Length == 0) { ClientLog.Instance.Log("Sec Kill has no target!"); return; } sk.Do(caster, Battle.Instance.GetActorByIdx((int)reportAction_.targets_[0].position_), DealAfterActionState); } return; default: if (reportAction_.status_ == OrderStatus.OS_None) { DealAfterActionState(); return; } else if (reportAction_.status_ == OrderStatus.OS_Zhuachong) { CatchBaby cb = new CatchBaby(); cb.Catch(reportAction_, DealAfterActionState); return; } else if (reportAction_.status_ == OrderStatus.OS_Summon) { // List<COM_Entity> entities = new List<COM_Entity>(reportAction_.dynamicEntities_); // Battle.Instance.AddNewActor(entities.ToArray());//, () => //// { //// DealAfterActionState(); //// }, reportAction_.dynamicEntities_.Length); // DealAfterActionState(); // return; break; } else { break; } } } if (reportAction_.targets_.Length == 0) { if (reportAction_.status_ == OrderStatus.OS_Summon) { mainSkillInst = new SkillInst(); mainSkillInst.Cast(reportAction_.skill_, reportAction_.skillLevel_, caster, null, reportAction_.targets_, FinishShow, DealCounterAction); } else { DealAfterActionState(); } return; } /// normal skill List <BattleActor> aims = new List <BattleActor>(); for (int i = 0; i < reportAction_.targets_.Length; ++i) { BattleActor item = Battle.Instance.GetActorByIdx((int)reportAction_.targets_[i].position_); // if( null == item || item.isDead ) continue; aims.Add(item); } //TODO for temp if (aims.Count == 0) { aims.Add(Battle.Instance.GetActorByInstId(reportAction_.casterId_)); } /////// for (int i = 0; i < aims.Count; ++i) { if (aims[i] == null) { continue; } aims[i].ForGuardPos = (int)reportAction_.huweiPosition_; } mainSkillInst = new SkillInst(); //ClientLog.Instance.Log("宠物 No! Cast: " + reportAction_.skill_ + " caster : " + caster.InstName + " aim: " + aims[0].InstName + " len:" + aims.Count + " target: " + reportAction_.targets_[0].position_ + " len:" + reportAction_.targets_.Length); mainSkillInst.Cast(reportAction_.skill_, reportAction_.skillLevel_, caster, aims.ToArray(), reportAction_.targets_, FinishShow, DealCounterAction); }); //// 处理需要除掉的actor //DealEraseActor(); }
public void Delete(Seckill seckill) { _seckillContext.Set <Seckill>().Remove(seckill); _seckillContext.SaveChanges(); }
public void Create(Seckill Seckill) { SeckillRepository.Create(Seckill); }
public IEnumerable <Seckill> GetSeckills(Seckill seckill) { return(SeckillRepository.GetSeckills(seckill)); }
public ActionResult <Seckill> PostSeckill(Seckill Seckill) { SeckillService.Create(Seckill); return(CreatedAtAction("GetSeckill", new { id = Seckill.Id }, Seckill)); }
public void Create(Seckill Seckill) { SeckillContext.Seckills.Add(Seckill); SeckillContext.SaveChanges(); }