public ActionResult checkout() { // checkout and done user = Session["user"] as Account; string deliveryMethod = Session["deliveryMethod"] as string; ViewBag.name = user.firstName; ViewBag.userID = user.userID; ViewBag.fullName = user.firstName + " " + user.lastName; ViewBag.currentAddress = user.currentAddress; ViewBag.contactNumber = user.phoneNo; ViewBag.email = user.email; ViewBag.placeOfBirth = user.placeOfBirth; ViewBag.method = deliveryMethod; MailingInformation mail = Session["mail"] as MailingInformation; DeliveryRate deliv = new DeliveryRate(); DeliveryRateManager dmanager = new DeliveryRateManager(); deliv = dmanager.getDeliveryRate(dmanager.getLocation(mail.locationID)); ViewBag.mailingID = mail.mailingID; ViewBag.mailingAddress = mail.streetname + " " + mail.addressline + " " + mail.city + " " + mail.country + " " + mail.zipcode; ViewBag.delivArea = deliv.location; ViewBag.delivCharge = deliv.price; ViewBag.dateNow = DateTime.Now.ToString(); ViewBag.dateCourier = DateTime.Now.AddDays(5).ToString(); ViewBag.dueDate = DateTime.Now.AddDays(5 + deliv.delay).ToString(); return(View()); }
/// <summary> /// Handles the result. /// </summary> /// <param name="canadaPostResponse">The response from Canada Post.</param> /// /// <param name="language">The language.</param> /// <returns></returns> private RequestResult HandleResult(string canadaPostResponse, CanadaPostLanguageEnum language) { var result = new RequestResult(); if (String.IsNullOrEmpty(canadaPostResponse)) { result.IsError = true; result.StatusCode = 0; result.StatusMessage = "Unable to connect to Canada Post."; return(result); } var doc = new XmlDocument(); doc.LoadXml(canadaPostResponse); XElement resultRates = XElement.Load(new StringReader(canadaPostResponse)); IEnumerable <XElement> query; // if we have any errors if (doc.GetElementsByTagName("error").Count > 0) { // query using LINQ the "error" node in the XML query = from errors in resultRates.Elements("error") select errors; XElement error = query.First(); if (error != null) { // set the status code information of the request result.StatusCode = Convert.ToInt32(error.Element("statusCode").Value); result.StatusMessage = error.Element("statusMessage").Value; result.IsError = true; } } else { // query using LINQ the "ratesAndServicesResponse" node in the XML because it contains // the actual status code information query = from response in resultRates.Elements("ratesAndServicesResponse") select response; XElement info = query.First(); // if we have informations if (info != null) { // set the status code information of the request result.StatusCode = Convert.ToInt32(info.Element("statusCode").Value); result.StatusMessage = info.Element("statusMessage").Value; // query using LINQ all the returned "product" nodes in the XML query = from prod in resultRates.Elements("ratesAndServicesResponse").Elements("product") select prod; foreach (XElement product in query) { // set the information related to this available rate var rate = new DeliveryRate(); rate.Sequence = Convert.ToInt32(product.Attribute("sequence").Value); rate.Name = product.Element("name").Value; rate.Amount = Convert.ToDecimal(product.Element("rate").Value, new CultureInfo("en-US", false).NumberFormat); DateTime shipDate; if (DateTime.TryParse(product.Element("shippingDate").Value, out shipDate) == true) { rate.ShippingDate = shipDate; } DateTime delivDate; if (DateTime.TryParse(product.Element("deliveryDate").Value, out delivDate) == true) { CultureInfo culture; if (language == CanadaPostLanguageEnum.French) { culture = new CultureInfo("fr-ca"); rate.DeliveryDate = delivDate.ToString("d MMMM yyyy", culture); } else { culture = new CultureInfo("en-us"); rate.DeliveryDate = delivDate.ToString("MMMM d, yyyy", culture); } } else { //rate.DeliveryDate = product.Element("deliveryDate").Value; rate.DeliveryDate = string.Empty; } result.AvailableRates.Add(rate); } query = from packing in resultRates.Elements("ratesAndServicesResponse").Elements("packing").Elements("box") select packing; foreach (XElement packing in query) { var box = new BoxDetail(); box.Name = packing.Element("name").Value; box.Weight = Convert.ToDouble(packing.Element("weight").Value, new CultureInfo("en-US", false).NumberFormat); box.ExpediterWeight = Convert.ToDouble(packing.Element("expediterWeight").Value, new CultureInfo("en-US", false).NumberFormat); box.Length = Convert.ToDouble(packing.Element("length").Value, new CultureInfo("en-US", false).NumberFormat); box.Width = Convert.ToDouble(packing.Element("width").Value, new CultureInfo("en-US", false).NumberFormat); box.Height = Convert.ToDouble(packing.Element("height").Value, new CultureInfo("en-US", false).NumberFormat); box.Quantity = Convert.ToInt32(packing.Element("packedItem").Element("quantity").Value); // add the box to the result result.Boxes.Add(box); } } } return(result); }
public ActionResult save(string email, string altEmail, string password, string lastName, string firstName, string middleName, string gender, string birthday, string citizenship, string birthPlace, string street, string city, string address, string country, string zipCode, string phoneNumber, string altPhoneNumber, string delivArea, string highSchool, string degreeLevel, string idNumber, string college, string degreeProgram, string gradRadio, string monthGraduate, string yearGraduate, string yrLvl, string lastTerm, string lastTermStart, string lastTermEnd, string admissionRadio, string admissionYear, string lastSchool, string campusAttended) { Account acc = new Account(); MailingInformation mail = new MailingInformation(); DeliveryRate deliv = new DeliveryRate(); Degree deg = new Degree(); // account acc.email = email; acc.alternateEmail = altEmail; acc.password = password; // personal acc.idNumber = idNumber; acc.lastName = lastName; acc.firstName = firstName; acc.middleName = middleName; if (gender == "Male") { acc.gender = 'M'; } else { acc.gender = 'F'; } string year = birthday[0] + "" + birthday[1] + "" + birthday[2] + "" + birthday[3] + ""; string month = birthday[5] + "" + birthday[6] + ""; string day = birthday[8] + "" + birthday[9] + ""; acc.birthYear = Int32.Parse(year); acc.birthMonth = Int32.Parse(month); acc.birthDay = Int32.Parse(day); acc.citizenship = citizenship; acc.placeOfBirth = birthPlace; acc.currentAddress = address; acc.phoneNo = phoneNumber; acc.alternatePhoneNo = altPhoneNumber; acc.registeredDate = DateTime.Now.ToString(); acc = manager.saveAccount(acc); // mailing deliv = delivManager.getDeliveryRate(delivArea); mail.zipcode = zipCode; mail.streetname = street; mail.city = city; mail.country = country; mail.locationID = deliv.locationId; mail.userID = acc.userID; mail.addressline = address; mail.contactPerson = firstName + " " + lastName; mail.contactNumber = phoneNumber; mailManager.addMailingInfo(mail); acc.mailInfos = mailManager.getMailInfos(acc.userID); // academic /*deg.degreeName = degreeProgram; * deg.level = degreeLevel; * deg.yearAdmitted = Int32.Parse(admissionYear); * deg.campusAttended = campusAttended; * deg.admittedAs = admissionRadio; * deg.graduated = gradRadio; * * if(yrLvl != "") * { * deg.yearLevel = Int32.Parse(yrLvl); * } * * * deg.userID = acc.userID; * * if(lastSchool != "") * { * deg.lastSchoolAttendedPrevDlsu = lastSchool; * } * * if(yearGraduate != "") * { * deg.graduatedYear = Int32.Parse(yearGraduate); * } * * if(monthGraduate != "") * { * deg.graduatedMonth = Int32.Parse(monthGraduate); * } * * if(lastTerm != "") * { * deg.term = Int32.Parse(lastTerm); * } * * if(lastTermStart != "") * { * int start = Int32.Parse(lastTermStart); * deg.academicYear = (start + 2000) + "-" + (start + 1 + 2000); * } */ //degManager.saveDegree(deg); //acc.degrees = degManager.getDegree(acc.userID); Session["user"] = acc; return(RedirectToAction("Order", "Transaction")); // go to next step //return RedirectToAction("Index", "Home"); }