public ActionResult UpdateAttributeValue(policyData vData, int id, int valueId, int linkId, FormCollection collection) { AttributeValueEntity attrValue = new AttributeValueEntity(valueId); if (attrValue.Literal) { attrValue.Value = collection["Literal"]; } else { if (collection["LookupId"] != null && collection["LookupId"] != string.Empty) { attrValue.AttributeId = int.Parse(collection["LookupId"]); } else { attrValue.AttributeId = null; } } attrValue.Save(); TempData["message"] = policyData.detailsSaved; return(RedirectToAction("EditMatch", new { id = id, linkId = linkId })); }
public ActionResult AddValue(policyData vData, int id, bool literal, int linkId) { AttributeValueEntity ave = new AttributeValueEntity(); ave.AttributeMatchId = id; ave.Literal = literal; AttributeValueCollection maxColl = new AttributeValueCollection(); PredicateExpression pe = new PredicateExpression(AttributeValueFields.AttributeMatchId == id); object maxObj = maxColl.GetScalar(AttributeValueFieldIndex.Order, null, AggregateFunction.Max, pe); if (maxObj != null && maxObj != DBNull.Value) { ave.Order = (int)maxObj + 1; } else { ave.Order = 0; } if (literal) { ave.Value = string.Empty; } else { ave.Value = null; } ave.Save(); return(RedirectToAction("EditMatch", new { id = id, linkId = linkId })); }
public ActionResult ValueOrder(policyData vData, int id, int id2, int linkId, FormCollection collection) { AttributeValueEntity attrValue = new AttributeValueEntity(id2); AttributeValueCollection coll = new AttributeValueCollection(); PredicateExpression pe = new PredicateExpression(AttributeValueFields.Id != attrValue.Id); pe.Add(AttributeValueFields.AttributeMatchId == id); SortExpression se = null; if (collection["up"] != null) { // Find all categories with display index less than ours. pe.Add(AttributeValueFields.Order <= attrValue.Order); // Order by display index, highest first. se = new SortExpression(AttributeValueFields.Order | SortOperator.Descending); } else { // Find all categories with display index greater than ours. pe.Add(AttributeValueFields.Order >= attrValue.Order); // Order by display index, lowest first. se = new SortExpression(AttributeValueFields.Order | SortOperator.Ascending); } // Swap with closest one. if (coll.GetMulti(pe, 1, se) && coll.Count > 0) { int temp = coll[0].Order; coll[0].Order = attrValue.Order; attrValue.Order = temp; attrValue.Save(); coll.SaveMulti(); } return(RedirectToAction("EditMatch", new { id = id, linkId = linkId })); }