public productsViewModel getProductDetail(int id)
        {
            productsViewModel model = new productsViewModel();

            AutoMapper.Mapper.Map(db.products.Find(id), model);
            return(model);
        }
        public int saveNewProduct(productsViewModel model)
        {
            int      result      = 0;
            products createModel = new products();

            AutoMapper.Mapper.Map(model, createModel);
            db.products.Add(createModel);
            if (db.SaveChanges() > 0)
            {
                result = createModel.id;
            }
            return(result);
        }
Esempio n. 3
0
 public ActionResult Detail(productsViewModel model)
 {
     if (_productService.updateProductDetail(model))
     {
         ToastrService.AddToUserQueue("Ürün başarıyla güncellendi.", "Kuaför Store", Data.Enums.ToastrType.Success);
         return(Redirect("~/urun-listesi"));
     }
     else
     {
         ToastrService.AddToUserQueue("Ürün bilgilerinde hata oluştu.", "Kuaför Store", Data.Enums.ToastrType.Error);
         return(View(model));
     }
 }
Esempio n. 4
0
 public ActionResult Create(productsViewModel model)
 {
     if (_productService.saveNewProduct(model) != 0)
     {
         ToastrService.AddToUserQueue("Ürün başarıyla oluşturuldu.", "Kuaför Store", Data.Enums.ToastrType.Success);
         return(Redirect("~/urun-listesi"));
     }
     else
     {
         ToastrService.AddToUserQueue("Ürün bilgilerinde hata oluştu.", "Kuaför Store", Data.Enums.ToastrType.Error);
         return(View(model));
     }
 }
        public bool updateProductDetail(productsViewModel model)
        {
            products updateModel = db.products.Find(model.id);

            AutoMapper.Mapper.Map(model, updateModel);
            updateModel.createDate = DateTime.Now;
            if (db.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }