protected LongRunningTaskStatusInfo processOrder(IConciergeAPIService api) { var processedOrderPacket = api.PreProcessOrder(targetOrder).ResultValue; cleanOrder = processedOrderPacket.FinalizedOrder.ConvertTo <msOrder>(); //Reset the total because a donation can be any amount - the product price returned from preprocessing is just the "suggested donation" cleanOrder.LineItems[0].Total = targetOrder.Total; // now, let's set the total - in case the product has added additional stuff like shipping/taxes cleanOrder.Total = cleanOrder.LineItems.Sum(x => x.Total); cleanOrder.PaymentMethod = OrderPaymentMethod.CreditCard; cleanOrder.CreditCardNumber = targetCreditCard.CardNumber; cleanOrder.CreditCardExpirationDate = targetCreditCard.CardExpirationDate; cleanOrder.CCVCode = targetCreditCard.CCVCode; cleanOrder.BillingAddress = acBillingAddress.Address; // cleanOrder.BillingEmailAddress = tbEmailAddress.Text; var info = api.ProcessOrder(cleanOrder, null).ResultValue; // let's wait return(OrderUtilities.WaitForOrderToComplete(api, info)); }
/// <summary> /// Ctor. /// </summary> /// <param name="orderUtilities"></param> public OrderStateBuilder( OrderUtilities orderUtilities, Sales.RmaService rmaService, MailService mailService, PersonService personService, RoleService roleService, AuthorizationService authorizationService, EventBroker eventBroker) { _orderUtilities = orderUtilities; _rmaService = rmaService; _mailService = mailService; _personService = personService; _eventBroker = eventBroker; _roleService = roleService; _authorizationService = authorizationService; }
public ActionResult Edit(Charge charge) { if (ModelState.IsValid) { try { // if the charge status has changed to active check that the order is active bool chargeStatus = (bool)TempData["ChargeStatus"]; if ((charge.IsValid != chargeStatus) && charge.IsValid == true) { Order orderForCharge = db.Orders.Find(charge.OrderID); if (orderForCharge.Status == false) { throw new Exception("Can't Change charge to active - charge order is not Active."); } } OrderUtilities.IsChargeAlert(charge); db.Entry(charge).State = EntityState.Modified; db.SaveChanges(); if (TempData["CameFromIndexFromOrderScreen"] != null) { if ((bool)TempData["CameFromIndexFromOrderScreen"] == true) { return(RedirectToAction("IndexFromOrderScreen", "Charge", new { id = charge.OrderID })); } else { return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ViewBag.errorMessage = e.Message; ViewBag.route = "Index"; return(View("Exception")); } } return(View(charge)); }
public ActionResult Edit(Client client) { if (ModelState.IsValid) { db.Entry(client).State = EntityState.Modified; //check if client status has changed to not active bool clientStatus = (bool)TempData["ClientStatus"]; if ((client.Status != clientStatus) && (client.Status == false)) { OrderUtilities.UpdateOrderOnClientEdit(client); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DistributorID = new SelectList(db.Distributors, "ID", "Name", client.DistributorID); ViewBag.ActivityTypeID = new SelectList(db.ActivityTypes, "ID", "Description", client.ActivityTypeID); ViewBag.CountryID = new SelectList(db.Countries, "ID", "Description", client.CountryID); ViewBag.PayTypeID = new SelectList(db.PayTypes, "ID", "Description", client.PayTypeID); ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "FullDescription", client.CurrencyID); return(View(client)); }
protected void Page_Load(object sender, EventArgs e) { orderUtilities = new OrderUtilities(); productUtilities = new ProductUtilities(); userUtilities = new UserUtilities(); if (!IsPostBack) { ddUserList.DataSource = orderUtilities.GetAllUserID(); ddUserList.DataBind(); } //GridView1.Visible = true; if (!(userUtilities.IsLoggedIn() && userUtilities.GetUserRole() == "Admin")) { Response.Redirect("Default.aspx"); } //Bind(3); }
public ActionResult Edit(Order order) { bool uneditedOrderStatus; try { uneditedOrderStatus = (bool)TempData["uneditedOrderStatus"]; if (ModelState.IsValid) { if (uneditedOrderStatus != order.Status) { Client clientOrder = db.Clients.Find(order.ClientID); if ((order.Status == true) && (clientOrder.Status == false)) { throw new Exception("Can't Change order Status To Active if the Order's Client is not Active"); } else { OrderUtilities.UpdateChargesOnOrderEdit(order); } } db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception e) { ErrorSignal.FromCurrentContext().Raise(e); ViewBag.errorMessage = e.Message; ViewBag.route = "Index"; return(View("Exception")); } ViewBag.ClientID = new SelectList(db.Clients, "ID", "Name", order.ClientID); ViewBag.PayConditionID = new SelectList(db.PayConditions, "ID", "Description", order.PayConditionID); //ViewBag.CurrencyID = new SelectList(db.Currencies, "ID", "Description", order.CurrencyID); return(View(order)); }
protected void RunReport_Click(object sender, EventArgs e) { //ReportViewer1.Visible is set to false in design mode TCRMDBContext db = new TCRMDBContext(); ChargesReportViewer.Visible = true; //define connection string SqlConnection thisConnection = new SqlConnection(thisConnectionString); System.Data.DataSet thisDataSet = new System.Data.DataSet(); //Get user Parameters SearchValue[0] = new SqlParameter("@startDate", chargeDateFromDatePicker.Text); SearchValue[1] = new SqlParameter("@endtDate", chargeDateToDatePicker.Text); SearchValue[2] = new SqlParameter("@clientName", ClientDDL.SelectedValue); SearchValue[3] = new SqlParameter("@distributorName", distributorDDL.SelectedValue); SearchValue[4] = new SqlParameter("@clientCountry", clientCountryDDL.SelectedValue); SearchValue[5] = new SqlParameter("@chargeFrequency", chargeFrequencyDDL.SelectedValue); SearchValue[6] = new SqlParameter("@isPaid", IsPaidCB.Checked); SearchValue[7] = new SqlParameter("@isValid", IsValidDDL.SelectedValue); SearchValue[8] = new SqlParameter("@isAlert", IsAlertCB.Checked); SearchValue[9] = new SqlParameter("@isInvoice", IsInvoiceCB.Checked); SearchValue[10] = new SqlParameter("@conversionRate", CurrencyDDL.SelectedValue); //check if the user chose "ALL" if (SearchValue[0].Value == "") { SearchValue[0] = null; } if (SearchValue[1].Value == "") { SearchValue[1] = null; } if (SearchValue[2].Value.ToString() == "ALL") { SearchValue[2] = null; } if (SearchValue[3].Value.ToString() == "ALL") { SearchValue[3] = null; } if (SearchValue[4].Value.ToString() == "ALL") { SearchValue[4] = null; } if (SearchValue[5].Value.ToString() == "ALL") { SearchValue[5] = null; } if (SearchValue[7].Value.ToString() == "ALL") { SearchValue[7] = null; } /*Add parameters to the SQL Stored Procedure*/ SqlCommand mySqlCommand = thisConnection.CreateCommand(); mySqlCommand.CommandText = "ChargesReport"; mySqlCommand.CommandType = CommandType.StoredProcedure; //Add DropDownList Parameters to the SP if (SearchValue[0] != null) { mySqlCommand.Parameters.Add("@startDate", SqlDbType.VarChar).Value = SearchValue[0].Value; } if (SearchValue[1] != null) { mySqlCommand.Parameters.Add("@endDate", SqlDbType.VarChar).Value = SearchValue[1].Value; } if (SearchValue[2] != null) { mySqlCommand.Parameters.Add("@clientName", SqlDbType.VarChar).Value = SearchValue[2].Value.ToString(); } if (SearchValue[3] != null) { mySqlCommand.Parameters.Add("@distributorName", SqlDbType.VarChar).Value = SearchValue[3].Value.ToString(); } if (SearchValue[4] != null) { mySqlCommand.Parameters.Add("@clientCountry", SqlDbType.VarChar).Value = SearchValue[4].Value.ToString(); } if (SearchValue[5] != null) { mySqlCommand.Parameters.Add("@chargeFrequency", SqlDbType.VarChar).Value = SearchValue[5].Value.ToString(); } //calculate conversion rate if (SearchValue[10].Value.ToString() == "System Currency") { mySqlCommand.Parameters.Add("@conversionRate", SqlDbType.Real).Value = 1; } else { int currencyID = Convert.ToInt32(SearchValue[10].Value); //if the system currency was chosen from the list (not as "System Currency") but as "Dollars" //for example which is the current system Currency if (currencyID == db.GlobalParameteres.First().CurrencyID) { mySqlCommand.Parameters.Add("@conversionRate", SqlDbType.Real).Value = 1; } else { double conversionRate = OrderUtilities.caculateCurrentConversion(currencyID); mySqlCommand.Parameters.Add("@conversionRate", SqlDbType.Real).Value = conversionRate; } } //define values to is valid based on DDL options if (SearchValue[7] != null) { if (SearchValue[7].Value.ToString() == "Yes") { mySqlCommand.Parameters.Add("@isValid", SqlDbType.Bit).Value = true; } if (SearchValue[7].Value.ToString() == "No") { mySqlCommand.Parameters.Add("@isValid", SqlDbType.Bit).Value = false; } } //Add checkbox parametes to the SP mySqlCommand.Parameters.Add("@isPaid", SqlDbType.Bit).Value = SearchValue[6].Value; mySqlCommand.Parameters.Add("@isAlert", SqlDbType.Bit).Value = SearchValue[8].Value; mySqlCommand.Parameters.Add("@isInvoice", SqlDbType.Bit).Value = SearchValue[9].Value; SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(); mySqlDataAdapter.SelectCommand = mySqlCommand; thisConnection.Open(); //load dataset with stored procedure result mySqlDataAdapter.Fill(thisDataSet); /********************************************************/ /* Associate thisDataSet (now loaded with the stored * procedure result) with the ReportViewer datasource */ ReportDataSource datasource = new ReportDataSource("ChargeReportDataSet", thisDataSet.Tables[0]); ChargesReportViewer.LocalReport.DataSources.Clear(); ChargesReportViewer.LocalReport.DataSources.Add(datasource); ChargesReportViewer.LocalReport.Refresh(); }
protected void btnPlaceOrder_Click(object sender, EventArgs e) { const string ContentSuffix = "_Contents"; if (!IsValid) { return; } lock (threadLock) { if (targetOrder == null) { Refresh(); return; } targetOrder.Notes = tbNotesComments.Text; // add cross sell var csi = MultiStepWizards.PlaceAnOrder.CrossSellItems; if (csi != null && csi.Count > 0) { targetOrder.LineItems.AddRange(csi.FindAll(x => x.Quantity != 0)); // add any cross sell items } using (var api = GetServiceAPIProxy()) { var msPayload = new List <MemberSuiteObject>(); // Go over line items and generate payoads for all attachments realted fields. foreach (var lineItem in targetOrder.LineItems) { // We're looking for _Content only. _Content has to be of MemberSuiteFile type. var attachments = lineItem.Fields.Where(f => f.Key.EndsWith(ContentSuffix) && IsNonEmptyMemberSuiteFile(f.Value)) .Select(c => { var msf = (MemberSuiteFile)c.Value; // Generate ID var fileId = api.GenerateIdentifer("File").ResultValue; // Create ms object... var mso = new MemberSuiteObject(); mso.ClassType = "File"; mso.Fields["ID"] = fileId; mso.Fields["FileContents"] = msf.FileContents; mso.Fields["Name"] = msf.FileName; mso.Fields["ContentLength"] = msf.FileContents.Length; return(new { Key = c.Key.Replace(ContentSuffix, string.Empty), FileId = fileId, File = mso }); }); if (attachments.Count() > 0) { foreach (var a in attachments) { // JES product fullfillment logic expects an xml file to save.. Copy relevant values into MemberSuiteFile & serializer it to send to JES (MS-6424) // var ms = new MemberSuiteFile(); ms.FileName = a.File.SafeGetValue <string>("Name"); ms.FileContents = a.File.SafeGetValue <byte[]>("FileContents"); ms.FileType = a.File.SafeGetValue <string>("FileType"); //we don't currently have this var xml = MemberSuite.SDK.Utilities.Xml.Serialize(ms); lineItem.Options.Add(new NameValueStringPair { Name = a.Key, Value = xml }); // Add according ms file to payload. msPayload.Add(a.File); } } } OrderPayload payload = MultiStepWizards.PlaceAnOrder.Payload; if (msPayload.Count() > 0) { if (payload == null) { payload = new OrderPayload(); } if (payload.ObjectsToSave == null) { payload.ObjectsToSave = new List <MemberSuiteObject>(); } payload.ObjectsToSave.AddRange(msPayload); } if (targetOrder.Date == DateTime.MinValue) { targetOrder.Date = DateTime.Now; } var processedOrderPacket = api.PreProcessOrder(targetOrder).ResultValue; cleanOrder = processedOrderPacket.FinalizedOrder.ConvertTo <msOrder>(); cleanOrder.Total = processedOrderPacket.Total; //if (string.IsNullOrWhiteSpace(cleanOrder.BillingEmailAddress)) // cleanOrder.BillingEmailAddress = CurrentUser.EmailAddress; if (MultiStepWizards.RegisterForEvent.IsSessionSwap) { var swapResult = api.SwapSessions( MultiStepWizards.RegisterForEvent.SwapRegistrationID, MultiStepWizards.RegisterForEvent.SessionsToCancel, cleanOrder); if (!swapResult.Success) { QueueBannerError(swapResult.FirstErrorMessage); } else { QueueBannerMessage("Session updates complete."); } MultiStepWizards.RegisterForEvent.Clear(); GoTo(MultiStepWizards.PlaceAnOrder.OrderCompleteUrl ?? "OrderComplete.aspx"); } var processInfo = api.ProcessOrder(cleanOrder, payload).ResultValue; // let's wait for the order var processStatus = OrderUtilities.WaitForOrderToComplete(api, processInfo); if (processStatus.Status == LongRunningTaskStatus.Failed) { throw new ConciergeClientException( MemberSuite.SDK.Concierge.ConciergeErrorCode.IllegalOperation, processStatus.AdditionalInfo); } string url = MultiStepWizards.PlaceAnOrder.OrderCompleteUrl ?? "OrderComplete.aspx"; if (url.Contains("?")) { url += "&"; } else { url += "?"; } targetOrder = null; // clear the cart if (isTransient) { // clear out the items if (MultiStepWizards.PlaceAnOrder.TransientShoppingCart != null) { MultiStepWizards.PlaceAnOrder.TransientShoppingCart.LineItems.Clear(); } MultiStepWizards.PlaceAnOrder.TransientShoppingCart = null; } else { MultiStepWizards.PlaceAnOrder.ShoppingCart = null; MultiStepWizards.PlaceAnOrder.RecentlyAddedItems = null; } MultiStepWizards.PlaceAnOrder.CrossSellItems = null; MultiStepWizards.PlaceAnOrder.EditOrderLineItem = null; // clear this out MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductName = null; // clear this out MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductDemographics = null; // clear this out MultiStepWizards.PlaceAnOrder.OrderConfirmationPacket = null; if (processStatus.Status == LongRunningTaskStatus.Running) { // MS-5204. Don't create job posting here. If JES is down then, job posting will be created // during order processing. Otherwise we'll endup with duplicate job postings. // hack - let's save the job posting //if (MultiStepWizards.PostAJob.JobPosting != null) // SaveObject(MultiStepWizards.PostAJob.JobPosting); MultiStepWizards.PostAJob.JobPosting = null; GoTo("OrderQueued.aspx"); } var order = LoadObjectFromAPI <msOrder>(processStatus.WorkflowID); QueueBannerMessage(string.Format("Order #{0} was processed successfully.", order.SafeGetValue <long>( msLocallyIdentifiableAssociationDomainObject.FIELDS.LocalID))); url += "orderID=" + order.ID; if (!url.Contains("contextID=")) { url += "&contextID=" + order.ID; } GoTo(url); } } }
public ActionResult SalePhase3(string orderPhase3Json) { Order orderPhase3 = new Order(); try { orderPhase3 = JsonConvert.DeserializeObject <Order>(orderPhase3Json); //Format SupportFirstChargeDate to dd/mm/yy JObject o = JObject.Parse(orderPhase3Json); string SupportFirstChargeDate = (string)o["SupportFirstChargeDateUnformatted"]; DateTime formattedDate = Convert.ToDateTime(SupportFirstChargeDate); orderPhase3.SupportFirstChargeDate = formattedDate; //check if totalNetPrice received a null due to redirection. orderPhase3.NetPrice = (double)TempData["totalNetPrice"]; } catch (JsonReaderException e) { //write exception to elmah log ErrorSignal.FromCurrentContext().Raise(e); ViewBag.errorMessage = e.Message; ViewBag.route = "SalePhase3"; return(View("Exception")); } try { Order orderPhase1 = (Order)TempData["orderPhase1"]; List <OrderItem> orderItems = (List <OrderItem>)TempData["orderItems"]; Charge charge = new Charge(); OrderUtilities.updateOrderOnSale(orderPhase1, orderPhase3); orderPhase1.orderItem = orderItems; db.Orders.Add(orderPhase1); foreach (OrderItem orderItem in orderItems) { db.OrderItems.Add(orderItem); } List <Charge> chargesList = OrderUtilities.calcChargesPeriodsOnSale(orderPhase1, charge); foreach (Charge chargeItem in chargesList) { db.Charges.Add(chargeItem); } if (ModelState.IsValid) { db.SaveChanges(); } else { //display exception to user return(RedirectToAction("Index")); } //catch exception if can't save data return(RedirectToAction("IndexFromOrderScreen", "Charge", new { id = orderPhase1.ID })); } catch (Exception e) { //write exception to elmah log ErrorSignal.FromCurrentContext().Raise(e); ViewBag.errorMessage = e.Message; ViewBag.route = "Index"; return(View("Exception")); } }
public ActionResult SalePhase2(string orderItems) { List <OrderItem> orderItemsList = new List <OrderItem>(); try { orderItemsList = JsonConvert.DeserializeObject <List <OrderItem> >(orderItems); //calculate orderItem net price based on conversion rates OrderUtilities.caculateOrderItemNetPriceWithConversion(orderItemsList); } catch (Exception e) { //write exception to elmah log ErrorSignal.FromCurrentContext().Raise(e); ViewBag.errorMessage = e.Message; ViewBag.route = "SalePhase2"; return(View("Exception")); } TempData["OrderItems"] = orderItemsList; double totalNetPrice = 0; double partOfServicePrice = 0; foreach (OrderItem orderItem in orderItemsList) { totalNetPrice += orderItem.NetPrice; if (orderItem.IsPartOfService == true) { partOfServicePrice += orderItem.NetPrice; } } TempData["partOfServicePrice"] = partOfServicePrice; TempData["totalNetPrice"] = totalNetPrice; //incase the totalNetPriceForSupport=0 , we need to skip the // the charges screen and finish the order. if (partOfServicePrice == 0) { try { Order orderWithoutCharges = new Order(); orderWithoutCharges = (Order)TempData["orderPhase1"]; orderWithoutCharges.Status = true; orderWithoutCharges.NetPrice = totalNetPrice; orderWithoutCharges.orderItem = orderItemsList; if (ModelState.IsValid) { db.Orders.Add(orderWithoutCharges); foreach (OrderItem orderItem in orderItemsList) { db.OrderItems.Add(orderItem); } db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } } catch (Exception e) { //write exception to elmah log ErrorSignal.FromCurrentContext().Raise(e); ViewBag.errorMessage = e.Message; ViewBag.route = "Index"; return(View("Exception")); } } TempData["RedirectFromPhase2"] = true; return(RedirectToAction("SalePhase3")); }
/// <summary> /// Ctor. /// </summary> /// <param name="orderUtilities"></param> public DeliveryStateBuilder( OrderUtilities orderUtilities, EventBroker eventBroker) { _orderUtilities = orderUtilities; _eventBroker = eventBroker; }