Ejemplo n.º 1
0
        public ActionResult Edit(ProductEditView model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    HttpCookie         reqCookies = Request.Cookies["StaffLoginCookie"];
                    ResponseStaffLogin login      = JsonConvert.DeserializeObject <ResponseStaffLogin>(reqCookies.Value.ToString().UrlDecode());
                    if (login == null)
                    {
                        return(Redirect("/System/Login"));
                    }

                    model.Vendor = login.ID;
                    if (_productBusiness.Edit(model))
                    {
                        _productBusiness.Save();
                        return(RedirectToAction("List"));
                    }
                }
                ViewBag.CategoryLst = _productCategoryBusiness.GetAll();
                return(View());
            }
            catch (Exception)
            {
                ViewBag.CategoryLst = _productCategoryBusiness.GetAll();
                return(View());
            }
        }
Ejemplo n.º 2
0
 private void Insert_Click(object sender, RoutedEventArgs e)
 {
     ProductEditView.IsEnabled  = true;
     ProductEditView.Visibility = Visibility.Visible;
     ProductEditView.Initialize();
     EditHeight.Height = new GridLength(210);
 }
Ejemplo n.º 3
0
 public bool Edit(ProductEditView model)
 {
     try
     {
         Product product = DbContext.Products.Find(model.ID);
         if (product != null)
         {
             if (!model.Avatar.Contains("http"))
             {
                 product.Avatar = "http://localhost:44351" + model.Avatar;
             }
             else
             {
                 product.Avatar = model.Avatar;
             }
             product.Category = model.Category;
             product.Content  = model.Content.Replace("\"/Content/FileUploads/", "\"http://localhost:44351/Content/FileUploads/");
             product.Desc     = model.Desc;
             product.Price    = model.Price;
             product.Status   = model.Status;
             product.Title    = model.Title;
             product.Staff    = model.Staff;
             return(true);
         }
         return(false);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
        private void Edit(int productId)
        {
            var view      = new ProductEditView();
            var entity    = Products.Single(x => x.ProductId == productId);
            var viewModel = new ProductEditViewModel(entity);

            view.DataContext = viewModel;
            view.ShowDialog();
        }
Ejemplo n.º 5
0
 private void Update_Click(object sender, RoutedEventArgs e)
 {
     if (ProductTable.SelectedIndex >= 0)
     {
         ProductCase Item = (dynamic)ProductTable.SelectedItem;
         ProductEditView.IsEnabled  = true;
         ProductEditView.Visibility = Visibility.Visible;
         ProductEditView.Initialize(Item);
         EditHeight.Height = new GridLength(120);
     }
 }
Ejemplo n.º 6
0
 public bool Edit(ProductEditView entity)
 {
     return(_product.Edit(entity));
 }