public JsonResult recieveBonus(int id)//id targerMaster { string UserId = getCurrentUserId(); var target = _targetServices.GetTargetbyUser(UserId); var targetMaster = _targetMasterServices.GetTargetMaster(id); if (target.CountImage >= targetMaster.Higher) { if (target.StatusBonus < targetMaster.Id) { int coinBonus = 0; int checkSum = 0; var checkList = _targetMasterServices.GetAllTargetMaster().Where(c => c.Id <= targetMaster.Id); if (checkList != null) { foreach (var item in checkList) { coinBonus += item.Bonus; if (target.StatusBonus >= item.Id) { checkSum += item.Bonus; } } } else { coinBonus = targetMaster.Bonus; } //cong coin bonus var claims = _claimsServices.GetClaimsbyUser(UserId); claims.CountImage = claims.CountImage + (coinBonus - checkSum); _claimsServices.UpdateClaims(claims); //update target target.StatusBonus = targetMaster.Id; _targetServices.UpdateTarget(target); return(Json(1, JsonRequestBehavior.AllowGet)); } } return(Json(0, JsonRequestBehavior.AllowGet)); }
public int UpdateTarget(Target target) { return(TargetServices.UpdateTarget(target)); }