/// <summary> /// Gets a test zone rate. /// </summary> /// <param name="project">Zone to include</param> /// <param name="zone">Zone</param> /// <returns>ZoneRate</returns> public static ZoneRate GetTestZoneRate(Project.Project project, Zone zone) { List <ShippingRate> shippingRates = new List <ShippingRate>(); foreach (string currency in project.Currencies) { Money money = new Money(); money.CentAmount = Helper.GetRandomNumber(99, 9999); money.CurrencyCode = currency; ShippingRate shippingRate = new ShippingRate(); shippingRate.Price = money; shippingRates.Add(shippingRate); } Reference zoneReference = new Reference(); zoneReference.Id = zone.Id; zoneReference.ReferenceType = Common.ReferenceType.Zone; ZoneRate zoneRate = new ZoneRate(); zoneRate.Zone = zoneReference; zoneRate.ShippingRates = shippingRates; return(zoneRate); }
public ActionResult DeleteConfirmed(int id) { ZoneRate zoneRate = db.ZoneRates.Find(id); db.ZoneRates.Remove(zoneRate); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ZoneRateID,ZoneRateDescription")] ZoneRate zoneRate) { if (ModelState.IsValid) { db.Entry(zoneRate).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(zoneRate)); }
public ActionResult Create([Bind(Include = "ZoneRateID,ZoneRateDescription")] ZoneRate zoneRate) { if (ModelState.IsValid) { db.ZoneRates.Add(zoneRate); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(zoneRate)); }
// GET: ZoneRate/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ZoneRate zoneRate = db.ZoneRates.Find(id); if (zoneRate == null) { return(HttpNotFound()); } return(View(zoneRate)); }
/// <summary> /// Creates a test shipping method draft. /// </summary> /// <returns>ShippingMethodDraft</returns> public static ShippingMethodDraft GetTestShippingMethodDraft(Project.Project project, TaxCategory taxCategory, Zone zone) { Reference taxCategoryReference = new Reference(); taxCategoryReference.Id = taxCategory.Id; taxCategoryReference.ReferenceType = Common.ReferenceType.TaxCategory; string name = string.Concat("Test Shipping Method ", Helper.GetRandomString(10)); ZoneRate zoneRate = Helper.GetTestZoneRate(project, zone); ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft(name, taxCategoryReference, new List <ZoneRate>() { zoneRate }); shippingMethodDraft.Description = "Created by commercetools.NET"; return(shippingMethodDraft); }