public void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            // System.Diagnostics.Debug.WriteLine("inside onchange method");
            ProductHub h = new ProductHub();

            h.Show();
        }
示例#2
0
        public ActionResult Create(ProdutCreationViewModel product)
        {
            try
            {
                LoadGender();
                ViewBag.ListCategories = LoadCategories();
                product.Gender         = GetGenderById(product.IdGender);
                string filePath = string.Empty;
                if (ModelState.IsValid)
                {
                    var saveFile = _saleFilesFromRequest.SaveFile(Request, Server.MapPath("~/Images/").ToString(), product);
                    filePath = ValidationPath(product, saveFile);
                    var productBussines = MappingUtility.MappFromProductViewToProductBO(product);
                    _commandProduct.AddProduct(productBussines);
                    //hub
                    ProductHub.ProductData();
                    ViewBag.Message = "Product created success";
                }
                else
                {
                    throw new NoValidaDataException("The form is not right please check it again");
                }


                return(View(LoadCategories()));
            }
            catch (FilesRequestFailedException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(LoadCategories()));
            }
            catch (NotValidExtentionException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(LoadCategories()));
            }
            catch (NoValidaDataException ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return(View(LoadCategories()));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "Ups something it's wrong please try again later";
                return(View(LoadCategories()));
            }
        }
示例#3
0
        public void ToComment(string content, int pid)
        {
            //登入的會員資訊
            CMember member = (CMember)Session[CMemberSession.Session_Login_User];

            CComment c = new CComment();

            c.fCommentDateTime = DateTime.UtcNow.AddHours(08);
            c.fContent         = content;
            c.fIsBanned        = false;
            c.fIsRetract       = false;
            c.fLikeCount       = 0;
            c.fMemberId        = member.fMemberId;
            c.fProductId       = pid;

            CCommentFactory.fn留言新增(c);

            var m = CMemberFactory.fn會員查詢().Where(z => z.fMemberId == member.fMemberId);

            GlobalHost.ConnectionManager.GetHubContext <ProductHub>().Clients.Group(ProductHub.getGroupIdString(pid)).newMessage(m.Single().fPhoto, m.Single().fTheNickName, DateTime.UtcNow.AddHours(08).ToString(), content);
        }
 private void SqlDependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     ProductHub.Show();
 }