public ActionResult ViewProduct(int id, string urlRedirect) { try { ViewBag.Message = urlRedirect; ViewProductViewModel model = new ViewProductViewModel(); ViewBag.Message = urlRedirect; if (Product.IsPrescriptionGlasses(id)) { PrescriptionGlasses p = new PrescriptionGlasses(id); model.Id = p.ProductId.ToString(); model.Name = p.Name; model.Price = decimal.Round(p.Price).ToString(); model.PrimaryImage = p.PrimaryImage; model.Lens = p.Lens.LensName; model.Description = p.ProductDescription; model.DiscountedPrice = decimal.Round(p.GetDiscountedPrice()).ToString(); if (p.Quantity == 0) { model.Status = "Out of Stock"; } else { model.Status = p.Quantity + " Item(s) available"; } model.Frame = p.Frame.FrameName; model.FrameColor = p.FrameColor; model.Images = p.Images; model.IsSunglasses = false; } else if (Product.IsSunglasses(id)) { Sunglasses s = new Sunglasses(id); model.Id = s.ProductId.ToString(); model.Name = s.Name; model.Price = decimal.Round(s.Price).ToString(); model.PrimaryImage = s.PrimaryImage; model.LensColor = s.LensColor; model.Description = s.ProductDescription; model.DiscountedPrice = decimal.Round(s.GetDiscountedPrice()).ToString(); if (s.Quantity == 0) { model.Status = "Out of Stock"; } else { model.Status = s.Quantity + " Item(s) remaining"; } model.FrameColor = s.FrameColor; model.Images = s.Images; model.IsSunglasses = true; } return(View(model)); } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Home", "ViewProduct"); return(RedirectToAction("Index", "Error", new { model = error })); } }
public ActionResult AnonymousOrderBuyerDetailsSubmission(BuyersInfoViewModel model, string id) { try { if (ModelState.IsValid) { City c = new City(Convert.ToInt32(model.CityName)); Buyer buyer = new Buyer(model.FullName, model.PhoneNumber, model.Address, model.Email, c); HttpCookie anonymusBuyer = new HttpCookie("anonBuyer"); anonymusBuyer.Value = buyer.BuyerId.ToString(); anonymusBuyer.Expires = DateTime.Now.AddMinutes(30); Response.Cookies.Add(anonymusBuyer); int productId = Convert.ToInt32(id); if (Product.IsPrescriptionGlasses(productId)) { PrescriptionGlasses p = new PrescriptionGlasses(productId); OrderPrescriptionGlassesViewModel opvm = new OrderPrescriptionGlassesViewModel() { DiscountedPrice = decimal.Round(p.GetDiscountedPrice()).ToString(), Id = p.ProductId.ToString(), Images = p.Images, Lens = p.Lens.LensName, Name = p.Name, Price = decimal.Round(p.Price).ToString(), DeliveryCharges = decimal.Round(buyer.City.DeliverCharges).ToString(), Status = p.Quantity + " Item(s) available", Quantity = p.Quantity }; ViewBag.Message = null; return(View("OrderPrescriptionGlasses", opvm)); } else { Sunglasses s = new Sunglasses(productId); OrderSunglassesViewModel osvm = new OrderSunglassesViewModel() { DiscountedPrice = decimal.Round(s.GetDiscountedPrice()).ToString(), Id = s.ProductId.ToString(), Images = s.Images, Name = s.Name, Price = decimal.Round(s.Price).ToString(), Status = s.Quantity + " Item(s) available", DeliveryCharges = decimal.Round(buyer.City.DeliverCharges).ToString(), Quantity = s.Quantity }; ViewBag.Message = null; return(View("OrderSunglasses", osvm)); } } else { return(View("OrderAnonymous", model)); } } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Cart", "AnonymousOrderBuyerDetailsSubmission"); return(RedirectToAction("Index", "Error", new { model = error })); } }
public ViewPrescriptionGlasses(PrescriptionGlasses prescriptionglass) { try { InitializeComponent(); prescriptionGlasses = prescriptionglass; lstIVM.Add(new ImagesViewModel { ImageName = prescriptionGlasses.PrimaryImage }); foreach (var item in prescriptionGlasses.Images) { if (item != prescriptionGlasses.PrimaryImage) { lstIVM.Add(new ImagesViewModel { ImageName = item }); } } Reset(); } catch (Exception ex) { MessageBoxes.Error(ex.Message); } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) { Response.Redirect("Default.aspx"); } else { user = (User)Session["User"]; user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "examinationassigned" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; } // if (Request.QueryString["PrescriptionGlassesId"] != null) { id = Int32.Parse(Request.QueryString["PrescriptionGlassesId"]); prescriptionGlasses = CntAriCli.GetPrescriptionGlasses(id, ctx); refractometry = prescriptionGlasses.Refractometry; LoadData(prescriptionGlasses); } if (Request.QueryString["RefractometryId"] != null) { id = int.Parse(Request.QueryString["RefractometryId"]); refractometry = (Refractometry)CntAriCli.GetExaminationAssigned(id, ctx); } }
protected void UnloadData(PrescriptionGlasses gt) { gt.FarAxisLeftEye = txtFarAxisLeftEye.Text; gt.FarAxisRightEye = txtFarAxisRightEye.Text; gt.FarCenters = txtFarCenter.Text; gt.FarCylinderLeftEye = txtFarCylinderLeftEye.Text; gt.FarCylinderRightEye = txtFarCylinderRightEye.Text; gt.FarPrismLeftEye = txtFarPrismLeftEye.Text; gt.FarPrimsRightEye = txtFarPrismRightEye.Text; gt.FarSphericityLeftEye = txtFarSphericityLefttEye.Text; gt.FarSphericityRightEye = txtFarSphericityRightEye.Text; gt.CloseAxisLeftEye = txtCloseAxisLeftEye.Text; gt.CloseAxisRightEye = txtCloseAxisRightEye.Text; gt.CloseCenters = txtCloseCenter.Text; gt.CloseCylinderLeftEye = txtCloseCylinderLeftEye.Text; gt.CloseCylinderRightEye = txtCloseCylinderRightEye.Text; gt.ClosePrismLeftEye = txtClosePrismLeftEye.Text; gt.ClosePrismRightEye = txtClosePrismRightEye.Text; gt.CloseSphericityLeftEye = txtCloseSphericityLefttEye.Text; gt.CloseSphericityRightEye = txtCloseSphericityRightEye.Text; gt.BothAxisLeftEye = txtBothAxisLeftEye.Text; gt.BothAxisRightEye = txtBothAxisRightEye.Text; gt.BothCenters = txtBothCenter.Text; gt.BothCylinderLeftEye = txtBothCylinderLeftEye.Text; gt.BothCylinderRightEye = txtBothCylinderRightEye.Text; gt.BothPrismLeftEye = txtBothPrismLeftEye.Text; gt.BothPrismRightEye = txtBothPrismRightEye.Text; gt.BothSphericityLeftEye = txtBothSphericityLefttEye.Text; gt.BothSphericityRightEye = txtBothSphericityRightEye.Text; gt.Comments = txtComments.Text; gt.SignMD = txtSignMD.Text; }
protected bool CreateChange(bool fromPrint) { if (!DataOk()) { return(false); } if (prescriptionGlasses == null) { prescriptionGlasses = new PrescriptionGlasses(); prescriptionGlasses.Refractometry = refractometry; UnloadData(prescriptionGlasses); ctx.Add(prescriptionGlasses); } else { prescriptionGlasses = CntAriCli.GetPrescriptionGlasses(prescriptionGlasses.Id, ctx); UnloadData(prescriptionGlasses); } ctx.SaveChanges(); if (!fromPrint) { RadAjaxManager1.ResponseScripts.Add(String.Format("showDialog('{0}','{1}','success',null,0,0)" , Resources.GeneralResource.Success , Resources.GeneralResource.CorrectlyStored)); Response.Redirect(String.Format("PrescriptionGlassesForm.aspx?PrescriptionGlassesId={0}", prescriptionGlasses.Id)); } return(true); }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) { Response.Redirect("Default.aspx"); } else { user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "rtickets" select p).FirstOrDefault <Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); } // cheks if is call from another form if (Request.QueryString["Report"] != null) { report = Request.QueryString["Report"]; } if (Request.QueryString["FDate"] != null) { fDate = CntWeb.ParseUrlDate(Request.QueryString["FDate"]); } if (Request.QueryString["TDate"] != null) { tDate = CntWeb.ParseUrlDate(Request.QueryString["TDate"]); } if (Request.QueryString["Diary"] != null) { diary = CntAriCli.GetDiary(int.Parse(Request.QueryString["Diary"]), ctx); } if (Request.QueryString["Visit"] != null) { visit = CntAriCli.GetVisit(int.Parse(Request.QueryString["Visit"]), ctx); } if (Request.QueryString["Treatment"] != null) { treatment = CntAriCli.GetTreatment(int.Parse(Request.QueryString["Treatment"]), ctx); } if (Request.QueryString["Invoice"] != null) { invoice = CntAriCli.GetInvoice(int.Parse(Request.QueryString["Invoice"]), ctx); } if (Request.QueryString["AmendmentInvoice"] != null) { aInvoice = CntAriCli.GetAmendementInvoice(int.Parse(Request.QueryString["AmendmentInvoice"]), ctx); } if (Request.QueryString["PrescriptionGlasses"] != null) { prescriptionGlasses = CntAriCli.GetPrescriptionGlasses(int.Parse(Request.QueryString["PrescriptionGlasses"]), ctx); } if (Request.QueryString["Estimate"] != null) { estimate = CntAriCli.GetEstimate(int.Parse(Request.QueryString["Estimate"]), ctx); } }
// GET: Home public ActionResult Index() { try { HomeViewModel model = new HomeViewModel(); List <HotItemsViewModel> lst = new List <HotItemsViewModel>(); foreach (var item in Product.GetHotItems()) { HotItemsViewModel hvm = new HotItemsViewModel() { Id = item.ProductId.ToString(), Image = item.PrimaryImage, Name = item.Name }; lst.Add(hvm); } model.HotItems = lst; List <FeaturedSunglassesViewModel> lstSunglasses = new List <FeaturedSunglassesViewModel>(); foreach (var item in Sunglasses.FeaturedSunglasses()) { FeaturedSunglassesViewModel fsvm = new FeaturedSunglassesViewModel() { Id = item.ProductId.ToString(), Name = item.Name, Image = item.PrimaryImage, Price = decimal.Round(item.Price).ToString() }; lstSunglasses.Add(fsvm); } model.PopSunglasses = lstSunglasses; List <FeaturedPrescriptionGlassesViewModel> lstPrescription = new List <FeaturedPrescriptionGlassesViewModel>(); foreach (var item in PrescriptionGlasses.FeaturedPrescriptionGlasses()) { FeaturedPrescriptionGlassesViewModel fpvm = new FeaturedPrescriptionGlassesViewModel() { Id = item.ProductId.ToString(), Name = item.Name, Image = item.PrimaryImage, Price = decimal.Round(item.Price).ToString() }; lstPrescription.Add(fpvm); } model.PopPrescriptionGlasses = lstPrescription; return(View(model)); } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Home", "Index"); return(RedirectToAction("Index", "Error", new { model = error })); } }
public ActionResult AddToCart(int id, string urlRedirect = null) { try { ViewBag.Message = urlRedirect; if (Product.IsSunglasses(id)) { Sunglasses s = new Sunglasses(id); OrderSunglassesViewModel osvm = new OrderSunglassesViewModel() { DeliveryCharges = decimal.Round(new Account(User.Identity.GetUserId()).Buyer.City.DeliverCharges).ToString(), DiscountedPrice = decimal.Round(s.GetDiscountedPrice()).ToString(), Id = s.ProductId.ToString(), Images = s.Images, Name = s.Name, Price = decimal.Round(s.Price).ToString(), Quantity = s.Quantity, Status = s.Quantity + " Item(s) available" }; return(View("OrderSunglasses", osvm)); } else if (Product.IsPrescriptionGlasses(id)) { PrescriptionGlasses p = new PrescriptionGlasses(id); OrderPrescriptionGlassesViewModel opvm = new OrderPrescriptionGlassesViewModel() { DeliveryCharges = decimal.Round(new Account(User.Identity.GetUserId()).Buyer.City.DeliverCharges).ToString(), DiscountedPrice = decimal.Round(p.GetDiscountedPrice()).ToString(), Id = p.ProductId.ToString(), Images = p.Images, Lens = p.Lens.LensName, Name = p.Name, Price = decimal.Round(p.Price).ToString(), Quantity = p.Quantity, Status = p.Quantity + " Item(s) available" }; return(View("OrderPrescriptionGlasses", opvm)); } return(View("Error")); } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Cart", "AddToCart"); return(RedirectToAction("Index", "Error", new { model = error })); } }
private bool Save() { if (CheckAllRequired() && radioSunglasses.Checked) { decimal price = Convert.ToDecimal(txtPrice.Text.Substring(3)); bool stopO = false; if (chkStopOrder.GetItemChecked(0)) { stopO = true; } string s = ""; Sunglasses sunglasses = new Sunglasses(txtName.Text, price, (int)numQuantity.Value, (int)numDiscount.Value, txtFrameColor.Text, txtDescription.Text, stopO, txtLensColor.Text); foreach (FileInfo item in fileNames) { s = UploadImageToFTP(item, sunglasses.ProductId); sunglasses.AddImage(s); } sunglasses.SetPrimaryImage(s); return(true); } else if (CheckAllRequired() && radioPrescriptionGlasses.Checked) { decimal price = Convert.ToDecimal(txtPrice.Text.Substring(3)); bool stopO = false; if (chkStopOrder.GetItemChecked(0)) { stopO = true; } string s = ""; PrescriptionGlasses prescrptionGlasses = new PrescriptionGlasses(txtName.Text, price, (int)numDiscount.Value, (int)numQuantity.Value, txtFrameColor.Text, txtDescription.Text, stopO, new Lens((int)comboLens.SelectedValue), new Frame((int)comboFrames.SelectedValue)); foreach (FileInfo item in fileNames) { s = UploadImageToFTP(item, prescrptionGlasses.ProductId); prescrptionGlasses.AddImage(s); } prescrptionGlasses.SetPrimaryImage(s); return(true); } return(false); }
protected void LoadData(PrescriptionGlasses pg) { txtFarAxisLeftEye.Text = pg.FarAxisLeftEye; txtFarAxisRightEye.Text = pg.FarAxisRightEye; txtFarCenter.Text = pg.FarCenters; txtFarCylinderLeftEye.Text = pg.FarCylinderLeftEye; txtFarCylinderRightEye.Text = pg.FarCylinderRightEye; txtFarPrismLeftEye.Text = pg.FarPrismLeftEye; txtFarPrismRightEye.Text = pg.FarPrimsRightEye; txtFarSphericityLefttEye.Text = pg.FarSphericityLeftEye; txtFarSphericityRightEye.Text = pg.FarSphericityRightEye; txtCloseAxisLeftEye.Text = pg.CloseAxisLeftEye; txtCloseAxisRightEye.Text = pg.CloseAxisRightEye; txtCloseCenter.Text = pg.CloseCenters; txtCloseCylinderLeftEye.Text = pg.CloseCylinderLeftEye; txtCloseCylinderRightEye.Text = pg.CloseCylinderRightEye; txtClosePrismLeftEye.Text = pg.ClosePrismLeftEye; txtClosePrismRightEye.Text = pg.ClosePrismRightEye; txtCloseSphericityLefttEye.Text = pg.CloseSphericityLeftEye; txtCloseSphericityRightEye.Text = pg.CloseSphericityRightEye; txtBothAxisLeftEye.Text = pg.BothAxisLeftEye; txtBothAxisRightEye.Text = pg.BothAxisRightEye; txtBothCenter.Text = pg.BothCenters; txtBothCylinderLeftEye.Text = pg.BothCylinderLeftEye; txtBothCylinderRightEye.Text = pg.BothCylinderRightEye; txtBothPrismLeftEye.Text = pg.BothPrismLeftEye; txtBothPrismRightEye.Text = pg.BothPrismRightEye; txtBothSphericityLefttEye.Text = pg.BothSphericityLeftEye; txtBothSphericityRightEye.Text = pg.BothSphericityRightEye; txtComments.Text = pg.Comments; txtSignMD.Text = pg.SignMD; }
// GET: Frames public ActionResult Index() { try { List <ViewFramesViewModel> model = new List <ViewFramesViewModel>(); foreach (var item in PrescriptionGlasses.GetAllPrescriptionGlasses()) { model.Add(new ViewFramesViewModel() { Id = item.ProductId.ToString(), Name = item.Name, Image = item.PrimaryImage, Price = decimal.Round(item.Price).ToString(), Discount = item.Discount.ToString() }); } return(View(model)); } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Frames", "Index"); return(RedirectToAction("Index", "Error", new { model = error })); } }
public ActionResult OrderPrescriptionGlasses(OrderPrescriptionGlassesViewModel model, string urlRedirect = null) { try { if (!ModelState.IsValid) { return(View(model)); } Buyer buyer; if (Request.IsAuthenticated) { buyer = new Account(User.Identity.GetUserId()).Buyer; } else if (Request.Cookies["anonBuyer"] != null) { buyer = new Buyer(Convert.ToInt32(Request.Cookies["anonBuyer"].Value)); Response.Cookies.Remove("anonBuyer"); } else { //return View which says that buyer's Session is timedout return(View("TimedOut")); } string fileName = Guid.NewGuid() + Path.GetFileName(model.Prescription.FileName); int productId = Convert.ToInt32(model.Id); if (buyer.GetCurrentCart() != null) { Cart c = buyer.GetCurrentCart(); PrescriptionGlasses p = new PrescriptionGlasses(productId); c.AddPrescriptionglasses(p, model.Quantity, fileName, model.Lens); string path = Server.MapPath(ConfigurationManager.AppSettings["PrescriptionsPath"] + fileName); model.Prescription.SaveAs(path); p.Quantity -= model.Quantity; if (urlRedirect == null) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(urlRedirect)); } } else { Cart c = new Cart(buyer); PrescriptionGlasses p = new PrescriptionGlasses(productId); c.AddPrescriptionglasses(p, model.Quantity, fileName, model.Lens); var url = Server.MapPath(ConfigurationManager.AppSettings["PrescriptionsPath"]); string path = url + fileName; model.Prescription.SaveAs(path); p.Quantity -= model.Quantity; if (urlRedirect != null && Request.IsAuthenticated) { return(Redirect(urlRedirect)); } else if (Request.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } Order order = new Order(c, DateTime.Now); OrderSuccessViewModel osvm = new OrderSuccessViewModel() { BuyersName = buyer.Name, DeliveryCharges = decimal.Round(buyer.City.DeliverCharges).ToString(), DiscountAvailed = order.Promo.Discount + "%", OrderId = order.OrderId.ToString(), Status = order.Status, TotalPrice = decimal.Round(order.TotalPrice).ToString() }; return(View("OrderSuccess", osvm)); } } catch (Exception ex) { HandleErrorInfo error = new HandleErrorInfo(ex, "Cart", "OrderPrescriptionGlasses"); return(RedirectToAction("Index", "Error", new { model = error })); } }