public static CheckoutData GetCheckoutData(Guid UserID = new Guid())
        {
            if (LS.CurrentHttpContext != null && LS.CurrentHttpContext.Items["CheckoutData"] != null)
            {
                return(LS.CurrentHttpContext.Items["CheckoutData"] as CheckoutData);
            }
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(null);
            }
            var checkoutData = LS.CurrentEntityContext.CheckoutDatas.FirstOrDefault(x => x.UserID == UserID);

            if (checkoutData == null)
            {
                //add to db if not exists
                checkoutData = new CheckoutData()
                {
                    UserID   = LS.CurrentUser.ID,
                    ShipTime = DateTime.Now,
                };
                LS.CurrentEntityContext.CheckoutDatas.Add(checkoutData);
                LS.CurrentEntityContext.SaveChanges();
            }
            if (LS.CurrentHttpContext != null)
            {
                LS.CurrentHttpContext.Items["CheckoutData"] = checkoutData;
            }
            return(checkoutData);
        }
Beispiel #2
0
        // its can be from child action and ajax loaded
        public ActionResult FooterCart(int ID = 0, bool tableonly = false)
        {
            var model = new ShoppingCartOverviewModel();

            if (LS.isHaveID())
            {
                if (ID == 0)
                {
                    if (LS.CurrentHttpContext.Session["ShopID"] != null)
                    {
                        ID = (int)LS.CurrentHttpContext.Session["ShopID"];
                    }
                    else
                    {
                        ID = ShoppingCartService.GetFirstShopID();
                    }
                }
                model = _shoppingCartService.GetShoppingCartModel(ID, withship: true);

                //_db.ShoppingCartItems.Where(x => x.UserID == LS.CurrentUser.ID).ToList();
            }

            if (!string.IsNullOrEmpty(model.Shop.Theme))
            {
                this.HttpContext.Items["ShopTheme"] = model.Shop.Theme;
            }

            if (tableonly)
            {
                return(PartialView("_CartTable", model));
            }
            return(PartialView(model));
        }
Beispiel #3
0
        // THis is how we retrieve an image and display it back into a button
        protected void GetImageTest_Click(object sender, EventArgs e)
        {
            LS Controller             = new LS();
            List <ImagePic> imageList = Controller.FindImagesByPostID(3);

            UI_ImgBtn_Test.ImageUrl = imageList.Last().ImagePath;
        }
Beispiel #4
0
        public ActionResult ChangeItem(int ID, decimal?Quantity, decimal?QuantityBit, bool?Delete, int?Attribute, int?qtype)
        {
            if (!LS.isHaveID())
            {
                return(Json(new { result = "error", action = "login", message = "You must login first", data = ID }));
            }

            var item = new ShoppingCartItem()
            {
                ID = ID
            };
            var addmodel = ShoppingCartService.AddToCart(LS.CurrentUser.ID, item, Quantity, QuantityBit, Delete, Attribute, qtype);

            if (addmodel.errors.Count > 0)
            {
                return(Json(new { result = "error", message = addmodel.errors.FirstOrDefault(), data = addmodel.item }));
            }
            bool withship = true;

            if (Request.UrlReferrer != null && Request.UrlReferrer.PathAndQuery.ToLower().Contains("shoppingcart"))
            {
                withship = true;
            }
            var model = _shoppingCartService.GetShoppingCartModel(addmodel.item.ShopID, loadattributes: false, withship: withship);

            var curCartItem = model.Items.FirstOrDefault(x => x.ID == ID); //GetShoppingCartItemByID(ID);

            if (curCartItem != null)
            {
                return(Json(new { result = "ok", data = curCartItem, cart = model }));
            }
            return(Json(new { result = "ok", data = addmodel.item, cart = model }));
        }
Beispiel #5
0
        public ActionResult OrderAjax([DataSourceRequest] DataSourceRequest request)
        {
            if (!LS.isHaveID())
            {
                return(Json(new { }));
            }
            //kendo reset manual sort to default =(
            if (request.Sorts == null)
            {
                request.Sorts = new List <SortDescriptor>();
            }
            if (request.Sorts.Count == 0)
            {
                request.Sorts.Add(new SortDescriptor("OrderStatus",
                                                     System.ComponentModel.ListSortDirection.Ascending));
                request.Sorts.Add(new SortDescriptor("ID",
                                                     System.ComponentModel.ListSortDirection.Descending));
            }
            var items = _db.Orders.Where(x => x.UserID == LS.CurrentUser.ID && !x.RegularOrder);

            DataSourceResult result = items.ToDataSourceResult(request);

            foreach (var item in (IEnumerable <Order>)result.Data)
            {
                item.TotalStr           = ShoppingService.FormatPrice(item.Total);
                item.RegularIntervalStr = RP.T("Enums." + item.RegularInterval.ToString()).ToString();
                item.OrderStatusStr     = RP.T("Enums." + item.OrderStatus.ToString()).ToString();
            }
            return(Json(result));
        }
Beispiel #6
0
        public ActionResult _GetCategoriesAjax(int shopID)
        {
            var allCategories = LS.Get <Category>();//.Select(x => new { x.ID, x.Name, x.ParentCategoryID })
            var model         = allCategories.Where(x => x.ParentCategoryID == 0).Select(x => new TreeModel()
            {
                ID       = x.ID,
                Name     = x.Name,
                ParentID = x.ParentCategoryID
            }).ToList();

            foreach (var ctree in model)
            {
                ctree.Childrens = allCategories.Where(x => x.ParentCategoryID == ctree.ID).Select(x => new TreeModel()
                {
                    ID       = x.ID,
                    Name     = x.Name,
                    Path     = "  " + ctree.Name + " >> ",
                    ParentID = x.ParentCategoryID
                }).ToList();
            }
            var sid = shopID;
            var currentShopModel = _db.ShopCategoryMenus.Where(x => x.ShopID == sid).ToList();

            return(Json(new { categoryTree = model, menu = currentShopModel }));
        }
        public int SendOrderUserCantPayToAdmin(Order order)
        {
            MethodBase            method = MethodBase.GetCurrentMethod();
            MailTemplateAttribute attr   = (MailTemplateAttribute)method.GetCustomAttributes(typeof(MailTemplateAttribute), true)[0];
            string templateSystemName    = attr.TemplateSystemName;

            var domain = _Context.EntityContext.SettingsAll.Select(x => x.AdminEmail).FirstOrDefault();
            var shop   = LS.Get <Shop>().FirstOrDefault(x => x.ID == order.ShopID);

            if (shop == null)
            {
                shop = new Shop();
            }
            var virtualUser = new User()
            {
                Email     = order.Email,
                FirstName = order.FullName != null ? order.FullName : "",
                ID        = order.UserID,
                Phone     = order.Phone,
                UserName  = order.Email
            };
            var res = Tokenize(templateSystemName, domain, new List <object>()
            {
                order, shop
                , virtualUser
            });

            return(res);
        }
        public int SendOrderChangedEmailToUser(Order order, List <OrderItem> changed, List <OrderItem> outOfStock)
        {
            MethodBase            method = MethodBase.GetCurrentMethod();
            MailTemplateAttribute attr   = (MailTemplateAttribute)method.GetCustomAttributes(typeof(MailTemplateAttribute), true)[0];
            string templateSystemName    = attr.TemplateSystemName;

            var productChangeds = new OrderChangedProductTable(changed);
            var productRemoved  = new OrderRemovedProductTable(outOfStock);
            var shop            = LS.Get <Shop>().FirstOrDefault(x => x.ID == order.ShopID);
            var virtualUser     = new User()
            {
                Email     = order.Email,
                FirstName = order.FullName != null ? order.FullName : "",
                ID        = order.UserID,
                Phone     = order.Phone,
                UserName  = order.Email
            };
            var res = Tokenize(templateSystemName, order.Email, new List <object>()
            {
                order
                , shop
                , virtualUser
                , productChangeds
                , productRemoved
            });

            return(res);
        }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // DISPLAYING ALL POSTS ON MAIN PAGE
            LS          Controller = new LS();
            List <Post> mainPosts  = Controller.FindMainForumPost();

            foreach (Post mp in mainPosts)
            {
                Main.Controls.Add(CreatePost(mp));
            }

            // DISPLAYING ALL THREADPOST
            int mainPostID = 1;

            /*
             * List<Post> threadPosts = Controller.FindThreadPostByMainPostReference(mainPostID);
             *
             * foreach(Post tp in threadPosts)
             * {
             *  // Dispaly UserName + Display DateTime
             *  // Display Title
             *  // Check if there's postText - and display it if true
             *  // Check if there's images and display all images
             *  // Display UpVote CB, Counter, DownVote CB, Add Reply Button
             * }
             */
            //            Post post = new Post(1, "henry", DateTime.Now, "title", "blah blah blah", 0, 0, true, 1, true);


            //Main.Controls.Add(CreatePost(post));
        }
Beispiel #10
0
    private void SubmitNewImagePost()
    {
        LS  Controller = new LS();
        int PostID     = 0;

        if (ImageFU.HasFiles)
        {
            // Add the post to the db and retrieve the PostID
            PostID = Controller.CreatePost("testuser", DateTime.Now, TitleTB.Text, "", true, null, true);

            // Create folder to store image for new main post
            string path = @"~/Images/PostID" + PostID.ToString() + @"/";

            if (!System.IO.Directory.Exists(Server.MapPath(@"~/Images/PostID" + PostID.ToString() + @"/")))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(path));
            }

            // Save image locally and store file path for each image
            foreach (HttpPostedFile file in ImageFU.PostedFiles)
            {
                file.SaveAs(Server.MapPath(path + file.FileName));
                Controller.AddImage(PostID, path + file.FileName);
            }

            Response.Redirect("~/Default.aspx");
        }
    }
Beispiel #11
0
        public ActionResult OrderItemAjaxDelete([DataSourceRequest] DataSourceRequest request, OrderItem model)
        {
            if (!LS.isHaveID())
            {
                ModelState.AddModelError("General", "You don't have permissions to edit this element");
                return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
            }
            var item = _db.OrderItems.FirstOrDefault(x => x.ID == model.ID);

            if (item != null)
            {
                var order = _db.Orders.FirstOrDefault(x => x.ID == item.OrderID);
                if (order != null)
                {
                    //check user
                    if (order.UserID != LS.CurrentUser.ID)
                    {
                        ModelState.AddModelError("General", "You don't have permissions to edit this element");
                        return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
                    }
                    decimal newCardTotal = order.Total;

                    newCardTotal += -item.UnitPrice;

                    order.Total = newCardTotal;
                    _db.OrderItems.Remove(item);
                    _db.SaveChanges();

                    return(Json(new[] { item }.ToDataSourceResult(request, ModelState)));
                }
            }


            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
Beispiel #12
0
        public ActionResult Activation(ActivationFormData data)
        {
            string code = data.part1 + data.part2 + data.part3 + data.part4 + data.part5;
            string mac  = new LS().mac();

            using (WebClient client = new WebClient())
            {
                NameValueCollection nvc = new NameValueCollection()
                {
                    { "activationData", "{\"mac_address\":\"" + mac + "\",\"package\":\"caresoft.softcom.co.ke\",\"code\":\"" + code + "\"}" }
                };



                try
                {
                    byte[] responseBytes = client.UploadValues("https://softcom.co.ke/apps/activation.php", nvc);
                    string response      = System.Text.Encoding.ASCII.GetString(responseBytes);

                    JObject json = JObject.Parse(response);
                    if (json.GetValue("active").ToString() == "Yes")
                    {
                        new LS().updateLicense("active");
                    }
                }catch (Exception e)
                {
                    return(Content("There was an error attempting to activate your copy of Caresoft HMS. Please check your internet connection and try again. If problem persists contact vendor for assistance."));
                }

                return(Redirect("Index"));
            }
        }
 public ActionResult LogOnAjx(LogOnModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (Membership.ValidateUser(model.UserName, model.Password))
         {
             var u = _db.Users.FirstOrDefault(x => x.UserName == model.UserName);
             LS.Authorize(u);
             bool haveOld = false;
             if (LS.CurrentHttpContext.Request.Cookies["SALcart"] != null)
             {
                 haveOld = true;
             }
             if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                 !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
             {
                 return(Json(new { result = "ok", url = returnUrl, haveOld = haveOld }));
             }
             else
             {
                 return(Json(new { result = "ok", haveOld = haveOld, url = Url.Action("DomainPage", "Page", new { name = "root" }) }));
                 //  eturn RedirectToAction("DomainPage", "Page", new { name = "root" });
             }
         }
         else
         {
             ModelState.AddModelError("", RP.T("Account.Logon.PasswordOrUserIncorrect").ToString());
         }
     }
     return(Json(new { result = "error", message = ModelState.Values.Select(x => new { Value = x.Value != null ? x.Value.AttemptedValue : "", errors = x.Errors.Select(y => y.ErrorMessage) }) }));
     //  return View(model);
 }
Beispiel #14
0
        public ActionResult _AjaxDetailAutoComplete([DataSourceRequest] DataSourceRequest request, string text)
        {
            var items = LS.Get <ProductSmall>(
                "ProductSmall", false, () =>
            {
                return(_db.Products.AsNoTracking()
                       .Select(x => new ProductSmall()
                {
                    ID = x.ID,
                    Image = x.Image,
                    Name = x.Name,
                    SKU = x.SKU
                })
                       .ToList());
            },
                "Product"
                ).AsQueryable();


            if (!string.IsNullOrEmpty(text))
            {
                items = items.Where(x => (x.SKU != null && x.SKU.Contains(text)) ||
                                    (x.Name != null && x.Name.Contains(text))
                                    );
            }
            request.PageSize = 100;
            DataSourceResult result = items.ToDataSourceResult(request);

            return(Json(result));
        }
Beispiel #15
0
        public ActionResult _AjaxIndex([DataSourceRequest] DataSourceRequest request)
        {
            IQueryable <Category> items  = _db.Categories.AsQueryable();
            DataSourceResult      result = items.ToDataSourceResult(request);

            var allCategories = LS.Get <Category>();

            foreach (var c in (IEnumerable <Category>)result.Data)
            {
                if (c.ParentCategoryID > 0)
                {
                    var pc = allCategories.FirstOrDefault(x => x.ID == c.ParentCategoryID);
                    if (pc != null)
                    {
                        c.ParentCategory = pc;
                    }
                }
                //cached product count
                c.CachedProductCount = LS.GetCachedFunc(() =>
                {
                    var cid = c.ID;
                    return(_db.Products.Where(x => x.Deleted == false && x.CategoryID == cid).Count());
                }, string.Format("productsInCategory-{0}.", c.ID), 60);
            }
            return(Json(result));
        }
 public ActionResult Contact(int?ID)
 {
     if (ID.HasValue)
     {
         if (TempData["ViewData"] != null)
         {
             ViewData = (ViewDataDictionary)TempData["ViewData"];
         }
         Contact contact = new Contact();
         var     shop    = LS.GetFirst <Shop>(x => x.ID == ID);
         if (shop != null)
         {
             contact.DropDownItems = new List <string> {
                 RP.T("Views.Shared.Contact.DropDownOneText").ToString(),
                 RP.T("Views.Shared.Contact.DropDownTwoText").ToString(),
                 RP.T("Views.Shared.Contact.DropDownThreeText").ToString(),
             };
             if (!string.IsNullOrEmpty(shop.Theme))
             {
                 this.HttpContext.Items["ShopTheme"] = shop.Theme;
             }
             contact.Shop = shop;
             return(View(contact));
         }
     }
     return(Redirect("~/Landing/Main/Index.html"));
 }
        public static void AddProductToFavorite(int ProductShopID, Guid UserID = new Guid())
        {
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return;
            }
            var fav = LS.CurrentEntityContext.ProductFavorites.FirstOrDefault(x => x.ProductShopID == ProductShopID &&
                                                                              x.UserID == UserID);

            if (fav == null)
            {
                UserActivityService.InsertFavoriteProduct(UserID, ProductShopID, false
                                                          , HttpContext.Current.Request.RawUrl,
                                                          HttpContext.Current.Request.UrlReferrer != null ? HttpContext.Current.Request.UrlReferrer.OriginalString : null
                                                          , LS.GetUser_IP(HttpContext.Current.Request));

                fav = new ProductFavorite()
                {
                    CreateDate    = DateTime.Now,
                    ProductShopID = ProductShopID,
                    UserID        = UserID
                };
                LS.CurrentEntityContext.ProductFavorites.Add(fav);
                LS.CurrentEntityContext.SaveChanges();
            }
        }
Beispiel #18
0
        private CheckoutData GetCheckoutData(Guid UserID = new Guid())
        {
            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(null);
            }
            var checkoutData = _db.CheckoutDatas.FirstOrDefault(x => x.UserID == UserID);

            if (checkoutData == null)
            {
                //add to db if not exists
                checkoutData = new CheckoutData()
                {
                    UserID   = LS.CurrentUser.ID,
                    ShipTime = DateTime.Now,
                };
                _db.CheckoutDatas.Add(checkoutData);
                _db.SaveChanges();
            }
            return(checkoutData);
        }
Beispiel #19
0
        private Message SendMessage(long chatId, string text, long replyTo, ref EchoOptions echoOptions)
        {
            Trace.WriteLine(text);
            if (echoOptions == null)
            {
                echoOptions = EchoOptions.SimpleEcho();
            }

#if ONECHAT_DEBUG
            text   = $"message to chat {chatId}: {text}";
            chatId = RealChat;
#endif
            var originalText = text;
            text = LS.Escape(text);    //todo: çäåñü ïðîáëåìà, ïîòîìó ÷òî âåðí¸òñÿ unescaped è ïîòîì îïÿòü áóäåò escape ïðè îáíîâëåíèè

            EchoOptions options = echoOptions;
            return(_limiter.RespectLimitForChat(chatId, () =>
            {
                TelemetryStatic.TelemetryClient.TrackEvent(TelemetryStatic.SendMessageKey, new Dictionary <string, string> {
                    [TelemetryStatic.ToChatKey] = chatId.ToString()
                });
                var result = _api.SendTextMessage(chatId, text, false, false, (int)replyTo, options.ReplyMarkup,
                                                  ParseMode.Markdown).FromResult2(text);

                var textProperty = result.GetType().GetProperty("Text");
                textProperty.SetValue(result, originalText);//todo: low dirty thing because escaping occure in wrong place

                return result;
            }));
        }
Beispiel #20
0
        public ActionResult ProductShop_AjaxAutoComplete([DataSourceRequest] DataSourceRequest request
                                                         , int ShopID, string text)
        {
            if (!LS.isHaveID())
            {
                return(Content(""));
            }
            //custom
            var items = (from ps in _db.ProductShopMap
                         join p in _db.Products
                         on ps.ProductID equals p.ID
                         where ps.ShopID == ShopID &&
                         p.Name.Contains(text)
                         select new
            {
                Name = (p.Name
                        // +" ("+ps.Price+")"
                        ),
                ID = ps.ID
            }).AsQueryable();
            DataSourceResult result = items.ToDataSourceResult(request);

            return(Json(result));

            //redirect to generic auto ready action
            // var generic = new BaseGenericController<ProductShop>();
            // generic._db = this._db;
            //sreturn generic._AjaxAutoComplete(request, text);
        }
Beispiel #21
0
        // This is how we store images locally
        protected void Test_Click(object sender, EventArgs e)
        {
            if (!UI_FUL_Image.HasFiles)
            {
                Response.Write("No file selected");
                return;
            }

            int PostID = 3;

            if (UI_FUL_Image.HasFiles)
            {
                string path = @"~/Images/PostID" + PostID.ToString() + @"/";
                if (!System.IO.Directory.Exists(Server.MapPath(@"~/Images/PostID" + PostID.ToString() + @"/")))
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(path));
                }

                UI_FUL_Image.SaveAs(Server.MapPath(path + UI_FUL_Image.FileName));
                LS Controller = new LS();

                bool Confirmation = Controller.AddImage(PostID, path + UI_FUL_Image.FileName);
                Response.Write(Confirmation);
            }
        }
Beispiel #22
0
        public ActionResult ReOrder(int ID)
        {
            if (!LS.isHaveID())
            {
                return(Json(new
                {
                    result = "error",
                    message = new Dictionary <string, Dictionary <string, List <string> > >()
                    {
                        { "general", new Dictionary <string, List <string> >()
                          {
                              { "errors", new List <string>()
                        {
                            "Please log in"
                        } }
                          } }
                    }
                }));
            }
            var order = _db.Orders.FirstOrDefault(x => x.ID == ID && x.UserID == LS.CurrentUser.ID);

            if (order != null)
            {
                // add to cart
                var items = _db.OrderItems.Where(x => x.OrderID == order.ID).ToList();
                foreach (var oi in items)
                {
                    if (oi.Quantity > 0)
                    {
                        ShoppingCartService.AddToCart(order.UserID, new ShoppingCartItem()
                        {
                            ProductAttributeOptionID = oi.ProductAttributeOptionID,
                            ProductShopID            = oi.ProductShopID,
                            Quantity = oi.Quantity,
                            ShopID   = order.ShopID,
                        });
                    }
                }

                return(Json(new
                {
                    result = "ok",
                    url = Url.Action("Index", "ShoppingCart", new { ID = order.ShopID })
                }));
            }
            return(Json(new
            {
                result = "error",
                message = new Dictionary <string, Dictionary <string, List <string> > >()
                {
                    { "general", new Dictionary <string, List <string> >()
                      {
                          { "errors", new List <string>()
                        {
                            "order not found"
                        } }
                      } }
                }
            }));
        }
Beispiel #23
0
 public ActionResult KeepOld(bool keep)
 {
     if (!LS.isHaveID())
     {
         return(Json(new { result = "error", action = "login", message = "You must login first" }));
     }
     if (LS.CurrentHttpContext.Request.Cookies["SALcart"] != null)
     {
         //retrieve old cart
         var oldGuid = new Guid(LS.CurrentHttpContext.Request.Cookies["SALcart"].Value);
         if (keep)
         {
             ShoppingCartService.MigrateShoppingCart(oldGuid, LS.CurrentUser.ID);
         }
         else
         {
             //remove old
             var forRemove = _db.ShoppingCartItems.Where(x => x.UserID == oldGuid).ToList();
             _db.ShoppingCartItems.RemoveRange(forRemove);
             _db.SaveChanges();
         }
         LS.DeleteCookie("SALcart");
     }
     return(Json(new { result = "ok" }));
 }
Beispiel #24
0
    // Use this for initialization
    IEnumerator Start()
    {
        yield return(null);

        //GameObjectsToSort = FindGameObjectsWithLayer(SL);

        //GameObjectsToSort = FindGameObjectsWithObject();


        LSOY = FindObjectsOfType <layerSortOnY>();


        foreach (layerSortOnY LS in LSOY)
        {
            //	if (LS.SortOnUpdate) {

            try {
                //GO.GetComponentInChildren<SpriteRenderer>().sortingOrder = Mathf.RoundToInt(transform.position.y * 100f) * -1;

                int idealOrder = Mathf.RoundToInt(LS.transform.position.y * 100f) * -1;

                LS.ReorderSprites(idealOrder);
            } catch {
            }
            //}
        }
    }
        public ActionResult LogOn(LogOnModel model, string returnUrl, string InvisibleCaptchaValue)
        {
            if (!CaptchaController.IsInvisibleCaptchaValid(InvisibleCaptchaValue))
            {
                ModelState.AddModelError(string.Empty, "Captcha error.");
                return(View());
            }

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    var u = _db.Users.FirstOrDefault(x => x.UserName == model.UserName);
                    LS.Authorize(u);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("DomainPage", "Page", new { name = "root" }));
                    }
                }
                else
                {
                    ModelState.AddModelError("", LocalizationHelpers.GetLocalResource("~/Views/Account/LogOn.cshtml", "UsernameIncorrect"));
                }
            }

            return(View(model));
        }
        /// <summary>
        /// return 0 if can`t add
        /// </summary>
        /// <param name="ShopID"></param>
        /// <param name="Rate"></param>
        /// <param name="UserID"></param>
        /// <returns>id of rate or 0 if cant add</returns>
        public static int AddShopRate(int ShopID, int Rate, Guid UserID = new Guid())
        {
            var rate = new ShopRate();

            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            if (UserID == Guid.Empty)
            {
                return(0);
            }
            if (LS.CurrentEntityContext.ShopRates.Any(x => x.ShopID == ShopID && x.UserID == UserID))
            {
                return(0);
            }
            rate.UserID = UserID;
            rate.Rate   = Rate;
            rate.ShopID = ShopID;

            LS.CurrentEntityContext.ShopRates.Add(rate);
            LS.CurrentEntityContext.SaveChanges();

            var shop = LS.CurrentEntityContext.Shops.FirstOrDefault(x => x.ID == ShopID);

            if (shop != null)
            {
                shop.Rate = (shop.Rate * shop.RateCount + Rate) / (shop.RateCount + 1);
                shop.RateCount++;
                LS.CurrentEntityContext.SaveChanges();
            }
            return(rate.ID);
        }
Beispiel #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Test
            LS Controller = new LS();
            //bool Confirmation = Controller.AddImage(7, "test from ui");
            //if (Confirmation)
            //{
            //    UI_LBL_Output1.Text = "Success";
            //}
            //else
            //    UI_LBL_Output1.Text = "failed";

            //bool Confirmation2 = Controller.CreatePost("kyung4Test", DateTime.Now, "last post on page 1", "This is just a random test", true, null, false);
            //Controller.CreatePost("kyung4Test", DateTime.Now, "last post on page 1", "first post on page 2???", true, null, false);
            //if (Confirmation2)
            //    UI_LBL_Output2.Text = "Success";
            //else
            //    UI_LBL_Output2.Text = "Fail";

            //bool Confirmation3 = Controller.CreatePost("kyung4Test", DateTime.Now, "TestingFromUI", "This is just a random test", false, 17, false);
            //if (Confirmation2)
            //    UI_LBL_Output3.Text = "Success";
            //else
            //    UI_LBL_Output3.Text = "Fail";
            //List<ImagePic> imageList = Controller.FindImagesByPostID(1);
            //foreach(ImagePic i in imageList)
            //{
            //    Response.Write(i.ImageID + ":" + i.ImagePath + "<br />");
            //}
            //List<Post> mainPosts = Controller.FindMainForumPost();
            //foreach (Post p in mainPosts)
            //{
            //    Response.Write("ThreadCount: " + Controller.GetThreadCount(p.MainPostReferenceID.Value)  + " PostID: " + p.PostID + ", UserName: "******", PostDate: " + p.PostDate + ", Title: " + p.Title +
            //       ", PostText: " + p.PostText + " UpCount: " + p.UpCount + " Counter: " + (p.UpCount - p.DownCount).ToString() + " DownCount: " + p.DownCount + "<br />");
            //}
            //List<Post> page1 = Controller.FindMainForumPostByPage(1);
            //foreach (Post p in page1)
            //{
            //    Response.Write("PostID: " + p.PostID + ", UserName: "******", PostDate: " + p.PostDate + ", Title: " + p.Title +
            //        ", PostText: " + p.PostText + " UpCount: " + p.UpCount + " Counter: " + (p.UpCount - p.DownCount).ToString() + " DownCount: " + p.DownCount + "<br />");
            //}
            //Response.Write("--------------------------------");
            //List<Post> page2 = Controller.FindMainForumPostByPage(2);
            //foreach (Post p in page2)
            //{
            //    Response.Write("PostID: " + p.PostID + ", UserName: "******", PostDate: " + p.PostDate + ", Title: " + p.Title +
            //        ", PostText: " + p.PostText + " UpCount: " + p.UpCount + " Counter: " + (p.UpCount - p.DownCount).ToString() + " DownCount: " + p.DownCount + "<br />");
            //}

            //List<Post> threadPosts = Controller.FindThreadPostByMainPostReference(1);
            //foreach (Post p in threadPosts)
            //{
            //    Response.Write("PostID: " + p.PostID + ", UserName: "******", PostDate: " + p.PostDate + ", Title: " + p.Title +
            //        ", PostText: " + p.PostText + " UpCount: " + p.UpCount + " Counter: " + (p.UpCount - p.DownCount).ToString() + " DownCount: " + p.DownCount + "<br />");
            //}

            //Controller.ModifyDownCount(1, 5);
            //Controller.ModifyUpCount(1, 8);
        }
        public ActionResult _Filters(int shopID)
        {
            //to do method
            //get filter list for shopID
            var filters = LS.GetForTest <SpecificationAttributeOption>(shopID).ToList();

            return(View(filters));
        }
 public ActionResult _RemoveProductFromFavorite(int productShopID)
 {
     if (LS.isLogined())
     {
         ShoppingService.RemoveProductFromFavorite(productShopID, LS.CurrentUser.ID);
     }
     return(Content(string.Empty));
 }
Beispiel #30
0
 public ActionResult Password()
 {
     UserActivityService.InsertUserClick(LS.CurrentUser.ID,
                                         Request.RawUrl,
                                         Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null
                                         , LS.GetUser_IP(Request));
     return(View());
 }