/// <summary> /// Display the infringments returned from the facade call. /// </summary> /// <param name="result">The result returned from the facade call containing the infringements.</param> private void DisplayInfringments(FacadeResult result) { // The update failed, display infringements. ruleInfringements.Infringements = result.Infringements; ruleInfringements.DisplayInfringments(); ruleInfringements.Visible = true; }
void btnRemoveAll_Click(object sender, EventArgs e) { if (OrderGroup != null && OrderGroup.Orders.Count > 0) { List <int> orderIDs = new List <int>(); foreach (Entities.Order order in OrderGroup.Orders) { if (!orderIDs.Contains(order.OrderID)) { orderIDs.Add(order.OrderID); } } Facade.IOrderGroup facOrderGroup = new Facade.Order(); FacadeResult result = facOrderGroup.RemoveOrdersFromGroup(OrderGroup.OrderGroupID, orderIDs, ((CustomPrincipal)User).UserName); if (result.Success) { RebindPage(); } else { DisplayInfringments(result); } } }
void cboGroupedPlanning_SelectedIndexChanged(object sender, EventArgs e) { if (OrderGroup != null) { OrderGroup.GroupedPlanning = bool.Parse(cboGroupedPlanning.SelectedValue); Facade.IOrderGroup facOrderGroup = new Facade.Order(); CustomPrincipal principal = (CustomPrincipal)User; FacadeResult result = facOrderGroup.Update(OrderGroup, principal.UserName); if (result.Success) { RebindPage(); } else { DisplayInfringments(result); } } }
void btnAssociate_Click(object sender, EventArgs e) { List <int> orderIDs = Orders; if (orderIDs.Count > 0) { this.RemoveOrdersFromOriginalGroup(); Facade.IOrderGroup facOrderGroup = new Facade.Order(); FacadeResult result = facOrderGroup.AddOrdersToGroup(_orderGroupID, orderIDs, ((CustomPrincipal)Page.User).UserName); if (result.Success) { //this.ClientScript.RegisterStartupScript(this.GetType(), "CallBack", "__dialogCallBack(window, 'refresh');", true); string orderIdsCSV = String.Empty; foreach (int orderId in orderIDs) { if (String.IsNullOrEmpty(orderIdsCSV)) { orderIdsCSV += orderId.ToString(); } else { orderIdsCSV += "," + orderId.ToString(); } } this.ReturnValue = orderIdsCSV; grdOrders.Rebind(); } else { // Cause the infringements to be displayed. DisplayInfringments(result); } } }
void grdOrders_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { switch (e.CommandName.ToLower()) { case "removeorder": int orderID = int.Parse(((GridDataItem)e.Item).GetDataKeyValue("OrderID").ToString()); List <int> orderIDs = new List <int>(1); orderIDs.Add(orderID); Facade.IOrderGroup facOrderGroup = new Facade.Order(); CustomPrincipal principal = (CustomPrincipal)User; FacadeResult result = facOrderGroup.RemoveOrdersFromGroup(OrderGroup.OrderGroupID, orderIDs, principal.UserName); if (result.Success) { RebindPage(); } else { DisplayInfringments(result); } break; } }
/// <summary> /// Creates a response based on facade results. /// </summary> /// <param name="request">The current http request.</param> /// <param name="facadeResult">Class containing facade results.</param> /// <returns>A response that can be return by a controller method.</returns> public static IHttpActionResult CreateApiResponse(this HttpRequestMessage request, FacadeResult facadeResult) { var errors = facadeResult.ErrorCodes? .Select(error => new { ErrorCode = error.Code, Message = error.Description }).ToList(); var response = request.CreateResponse((HttpStatusCode)facadeResult.StatusCode); response.Content = new StringContent(errors.ToJsonFormatted()); return(new ResponseMessageResult(response)); }