public SqlRawParameter GetSqlRawParameter(SourceCategory parameters) { if (parameters == null) { return(new SqlRawParameter()); } var sqlQry = new StringBuilder(); sqlQry.AppendLine("SELECT * FROM SourceCategories"); var whereClauses = new List <string>(); var sqlParams = new List <SqlParameter>(); if (!parameters.Description.IsNull()) { sqlParams.Add(new SqlParameter(nameof(parameters.Description).Parametarize(), parameters.Description)); whereClauses.Add($"{nameof(parameters.Description)} = {nameof(parameters.Description).Parametarize()}"); } if (!parameters.IsActive.IsNull()) { sqlParams.Add(new SqlParameter(nameof(parameters.IsActive).Parametarize(), parameters.IsActive)); whereClauses.Add($"{nameof(parameters.IsActive)} = {nameof(parameters.IsActive).Parametarize()}"); } if (whereClauses.Count > 0) { sqlQry.AppendLine(" WHERE "); sqlQry.AppendLine(String.Join(" AND ", whereClauses.ToArray())); } return(new SqlRawParameter() { SqlParameters = sqlParams, SqlQuery = sqlQry.ToString() }); }
public DamageInfo(DamageDef def, float amount, float armorPenetration = 0f, float angle = -1f, Thing instigator = null, BodyPartRecord hitPart = null, ThingDef weapon = null, SourceCategory category = SourceCategory.ThingOrUnknown, Thing intendedTarget = null) { defInt = def; amountInt = amount; armorPenetrationInt = armorPenetration; if (angle < 0f) { angleInt = Rand.RangeInclusive(0, 359); } else { angleInt = angle; } instigatorInt = instigator; categoryInt = category; hitPartInt = hitPart; heightInt = BodyPartHeight.Undefined; depthInt = BodyPartDepth.Undefined; weaponInt = weapon; weaponBodyPartGroupInt = null; weaponHediffInt = null; instantPermanentInjuryInt = false; allowDamagePropagationInt = true; ignoreArmorInt = false; ignoreInstantKillProtectionInt = false; intendedTargetInt = intendedTarget; }
//添加分类 protected void btnSubAdd_Click(object sender, EventArgs e) { string category = txtCategory.Text; if (category.Length == 0) { JSHelper.ShowAlert("输入不能为空!"); } else if (checkCategoryNameExit(category)) { JSHelper.ShowAlert("该分类已存在!"); } else { using (var db = new TeachingCenterEntities()) { var cate = new SourceCategory(); cate.SourceCategory_name = category; db.SourceCategory.Add(cate); db.SaveChanges(); Server.Transfer("SrcCatManage.aspx"); //JSHelper.AlertThenRedirect("添加成功!", "ActivityCatagoryManage.aspx"); //Server.Transfer("ActivityCatagoryManage.aspx"); } } }
public IActionResult Put([FromBody] SourceCategory model) { try { if (!ModelState.IsValid) { return(InvalidModelStateResult()); } if (!validateEntity(model)) { return(InvalidModelStateResult()); } if (repository.Get().Count(a => a.SourceCategoryId.Equals(model.SourceCategoryId)) == 0) { return(NotFound(Constants.ErrorMessages.NotFoundEntity)); } return(Accepted(repository.Update(model))); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.UpdateError)); } }
public static int getId(string name) { using (var db = new TeachingCenterEntities()) { SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_name == name); return(sc.SourceCategory_id); } }
public static string getCategoryName(int id) { using (var db = new TeachingCenterEntities()) { SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_id == id); return(sc.SourceCategory_name); } }
public async Task <ActionResult> DeleteConfirmed(int id) { SourceCategory sourceCategory = await db.SourceCategories.FindAsync(id); db.SourceCategories.Remove(sourceCategory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
private bool validateEntity(SourceCategory model) { var validName = repository.ValidateName(model); if (!validName) { ModelState.AddModelError(nameof(SourceCategory.Description), Constants.ErrorMessages.EntityExists("Description")); } return(ModelState.ErrorCount == 0); }
public bool ValidateName(SourceCategory model) { var existing = Get().FirstOrDefault(a => a.Description == model.Description.Trim()); if (existing == null) { return(true); } return(existing.SourceCategoryId == model.SourceCategoryId); }
public IQueryable <SourceCategory> Get(SourceCategory parameters = null) { var sqlRawParams = GetSqlRawParameter(parameters); if (sqlRawParams.SqlParameters.Count == 0) { return(dbContext.SourceCategories.AsNoTracking()); } return(dbContext.SourceCategories.FromSqlRaw(sqlRawParams.SqlQuery, sqlRawParams.SqlParameters.ToArray()).AsNoTracking()); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name")] SourceCategory sourceCategory) { if (ModelState.IsValid) { db.Entry(sourceCategory).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(sourceCategory)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name")] SourceCategory sourceCategory) { if (ModelState.IsValid) { db.SourceCategories.Add(sourceCategory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(sourceCategory)); }
public IActionResult Get([FromQuery] SourceCategory parameters = null) { try { var model = repository.Get(parameters); return(Ok(model)); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.FetchError)); } }
// GET: SourceCategories/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SourceCategory sourceCategory = await db.SourceCategories.FindAsync(id); if (sourceCategory == null) { return(HttpNotFound()); } return(View(sourceCategory)); }
public SourceCategory Update(SourceCategory model) { var entity = dbContext.SourceCategories.Find(model.SourceCategoryId); if (entity == null) { throw new Exception("Selected Record does not exists."); } entity.Description = model.Description; dbContext.SourceCategories.Update(entity); dbContext.SaveChanges(); return(entity); }
public DamageInfo(DamageInfo cloneSource) { this.defInt = cloneSource.defInt; this.amountInt = cloneSource.amountInt; this.angleInt = cloneSource.angleInt; this.instigatorInt = cloneSource.instigatorInt; this.categoryInt = cloneSource.categoryInt; this.hitPartInt = cloneSource.hitPartInt; this.heightInt = cloneSource.heightInt; this.depthInt = cloneSource.depthInt; this.weaponInt = cloneSource.weaponInt; this.weaponBodyPartGroupInt = cloneSource.weaponBodyPartGroupInt; this.weaponHediffInt = cloneSource.weaponHediffInt; this.instantOldInjuryInt = cloneSource.instantOldInjuryInt; this.allowDamagePropagationInt = cloneSource.allowDamagePropagationInt; }
public DamageInfo(DamageInfo cloneSource) { defInt = cloneSource.defInt; amountInt = cloneSource.amountInt; armorPenetrationInt = cloneSource.armorPenetrationInt; angleInt = cloneSource.angleInt; instigatorInt = cloneSource.instigatorInt; categoryInt = cloneSource.categoryInt; hitPartInt = cloneSource.hitPartInt; heightInt = cloneSource.heightInt; depthInt = cloneSource.depthInt; weaponInt = cloneSource.weaponInt; weaponBodyPartGroupInt = cloneSource.weaponBodyPartGroupInt; weaponHediffInt = cloneSource.weaponHediffInt; instantPermanentInjuryInt = cloneSource.instantPermanentInjuryInt; allowDamagePropagationInt = cloneSource.allowDamagePropagationInt; intendedTargetInt = cloneSource.intendedTargetInt; }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { using (var db = new TeachingCenterEntities()) { int count = 0; for (int i = 0; i < this.rptCategory.Items.Count; i++) { CheckBox cbx = (CheckBox)rptCategory.Items[i].FindControl("chbCheck"); if (cbx != null) { if (cbx.Checked == true) { count++; } } } var list = from it in db.SourceCategory select it; if (list.Count() == count) { JSHelper.ShowAlert("请至少留有一个分类!"); } else { for (int i = 0; i < rptCategory.Items.Count; i++) { CheckBox cbx = (CheckBox)rptCategory.Items[i].FindControl("chbCheck"); string name = ((Literal)rptCategory.Items[i].FindControl("ltName")).Text; if (cbx != null) { if (cbx.Checked == true) { SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_name == name); db.SourceCategory.Remove(sc); db.SaveChanges(); } } } //JSHelper.AlertThenRedirect("删除成功!", "ActivityCatagoryManage.aspx"); Server.Transfer("SrcCatManage.aspx"); } } }
public IActionResult Post([FromBody] SourceCategory model) { try { if (!ModelState.IsValid) { return(InvalidModelStateResult()); } if (!validateEntity(model)) { return(InvalidModelStateResult()); } return(Accepted(repository.Create(model))); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.CreateError)); } }
public IActionResult ValidateName([FromBody] SourceCategory model) { if (model == null) { return(NotFound()); } if (General.IsDevelopment) { logger.LogDebug(ModelState.ToJson()); } var result = repository.ValidateName(model); if (result) { return(Accepted(true)); } else { return(UnprocessableEntity(Constants.ErrorMessages.EntityExists("Name"))); } }
//修改分类 protected void btnChange_Click(object sender, EventArgs e) { if (txtChange.Text.Length == 0) { JSHelper.ShowAlert("输入不能为空!"); } else if (checkCategoryNameExit(txtChange.Text)) { JSHelper.ShowAlert("该分类已存在!"); } else { using (var db = new TeachingCenterEntities()) { int id = Convert.ToInt32(lbID.Text); SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_id == id); sc.SourceCategory_name = txtChange.Text; db.SaveChanges(); Server.Transfer("SrcCatManage.aspx"); // JSHelper.AlertThenRedirect("修改成功!", "ActivityCatagoryManage.aspx"); } } }
public DamageInfo(DamageDef def, int amount, float angle = -1f, Thing instigator = null, BodyPartRecord hitPart = null, ThingDef weapon = null, SourceCategory category = SourceCategory.ThingOrUnknown) { this.defInt = def; this.amountInt = amount; if (angle < 0.0) { this.angleInt = (float)Rand.RangeInclusive(0, 359); } else { this.angleInt = angle; } this.instigatorInt = instigator; this.categoryInt = category; this.hitPartInt = hitPart; this.heightInt = BodyPartHeight.Undefined; this.depthInt = BodyPartDepth.Undefined; this.weaponInt = weapon; this.weaponBodyPartGroupInt = null; this.weaponHediffInt = null; this.instantOldInjuryInt = false; this.allowDamagePropagationInt = true; }
protected void rptCategory_ItemCommand(object source, RepeaterCommandEventArgs e) { //删除专题分类 if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument.ToString()); using (var db = new TeachingCenterEntities()) { var list = from it in db.SourceCategory select it; if (list.Count() == 1) { JSHelper.ShowAlert("已经是最后一个分类了!"); } else { SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_id == id); db.SourceCategory.Remove(sc); db.SaveChanges(); //JSHelper.AlertThenRedirect("删除成功!", "ActivityCatagoryManage.aspx"); Server.Transfer("SrcCatManage.aspx"); } } } //修改分类 if (e.CommandName == "Editor") { int id = Convert.ToInt32(e.CommandArgument.ToString()); lbID.Text = id.ToString(); using (var db = new TeachingCenterEntities()) { SourceCategory sc = db.SourceCategory.Single(a => a.SourceCategory_id == id); txtChange.Text = sc.SourceCategory_name; } divEditor.Visible = true; } }
public SourceTerm(SourceCategory sourceCategory, Dictionary <string, double> table) { SourceCategory = sourceCategory; _table = table; }
public ISoundVoice StartPlay3D(string soundAlias, float volume, Vector3 position, SourceCategory Category = SourceCategory.FX, bool playLooped = false, uint minDefferedStart = 0, uint maxDefferedStart = 0) { return(StartPlay3D(AddSoundSourceFromFile(null, soundAlias, Category), position, volume, playLooped, minDefferedStart, maxDefferedStart)); }
public bool ValidateCode(SourceCategory model) { throw new NotImplementedException(); }
public ISoundVoice StartPlay3D(string FilePath, string soundAlias, Vector3 position, SourceCategory Category = SourceCategory.FX, bool playLooped = false, uint minDefferedStart = 0, uint maxDefferedStart = 0, int priority = 0) { return(StartPlay3D(AddSoundSourceFromFile(FilePath, soundAlias, Category, priority: priority), position, playLooped, minDefferedStart, maxDefferedStart)); }
public bool Delete(SourceCategory model) { dbContext.SourceCategories.Remove(model); dbContext.SaveChanges(); return(true); }
public SourceCategory Create(SourceCategory model) { dbContext.SourceCategories.Add(model); dbContext.SaveChanges(); return(model); }
public override int GetHashCode() { return(ItemId.GetHashCode() + SourceCategory.GetHashCode()); }
public Task<SearchItemsResponse> SearchItems(ImpactEffect? impactEffects = null, GuardianAttribute? guardianAttributes = null, LightAbility? lightAbilities = null, DamageType? damageTypes = null, SourceCategory? sourcecat = null, long? sourcehash = null, bool? matchrandomsteps = null, bool? definitions = null, long? categories = null, SortOrder? order = null, WeaponPerformance? weaponPerformance = null, Rarity? rarity = null, int? page = null, string name = null, Count? count = null, bool? orderstathash = null, SortDirection? direction = null, long? step = null) { var model = new { impactEffects, guardianAttributes, lightAbilities, damageTypes, sourcecat, sourcehash, matchrandomsteps, definitions, categories, order, weaponPerformance, rarity, page, name, count, orderstathash, direction, step }; return Request<SearchItemsResponse>(model); }