예제 #1
0
 public bool Save(Products_Model model)
 {
     using (var _context = new SalesTrackingSystemEntities())
     {
         try
         {
             var data = new Product()
             {
                 ProductID         = GetNewProductID(),
                 ProductCategoryID = model.ProductCategoryID,
                 ProductName       = model.ProductName,
                 PackRate          = model.PackRate,
                 UnitId            = model.UnitId,
                 Description       = model.Description,
                 DateCreated       = DateTime.Now
             };
             _context.Products.Add(data);
             _context.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
 public PresenteProductDoctor_ViewModel(INavigation navigation, Products_Model product)
 {
     Navigation = navigation;
     Product    = product;
     AddPresentePorodctCommand = new Command(async() =>
     {
         await ExecuteOnAddPresentedProduct();
     });
 }
예제 #3
0
 public ActionResult DeleteProduct(Products_Model model)
 {
     try
     {
         if (productService.Delete(model.ProductID))
         {
             return(Json(model.ProductName + " has been deleted successfully"));
         }
         else
         {
             return(Json("Error"));
         }
     }
     catch (Exception e)
     {
         return(Json("Error" + e.ToString()));
     }
 }
예제 #4
0
 public ActionResult AddProduct(Products_Model product_Model)
 {
     if (product_Model.ProductName == null || product_Model.ProductCategoryID == null)
     {
         ViewBag.AddProduct = "Error";
         return(View("Products"));
     }
     else
     {
         if (productService.Save(product_Model))
         {
             Session["Success"] = "Product Category inserted succcessfully";
             return(RedirectToAction("Products"));
         }
         else
         {
             Session["Error"] = "Error occured!!";
             return(View("Products"));
         }
     }
 }
 public ProductDetail_ViewModel(INavigation navigation, Products_Model product)
 {
     Navigation           = navigation;
     Product              = product;
     PictureTappedCommand = new Command(async() =>
     {
         await ExecuteOnPictureTapped();
     });
     ItemTappedCommand = new Command(() =>
     {
         ExecuteOnRivalProductTapped();
     });
     HidePopUpCommand = new Command(() =>
     {
         ExecuteOnPopUpHide();
     });
     RivalPictureTappedCommand = new Command(async() =>
     {
         await ExecuteOnRivalPictureTapped();
     });
 }
예제 #6
0
 public ActionResult UpdateProduct(Products_Model model)
 {
     if (string.IsNullOrWhiteSpace(model.ProductName) || model.ProductCategoryID == 0)
     {
         ViewBag.ProductUpdateError = "Error";
         ViewBag.UpdateProductData  = model.ProductID;
         return(View("Products"));
     }
     else
     {
         if (productService.Update(model))
         {
             Session["Success"] = model.ProductName + " updated successfully!!";
             return(RedirectToAction("Products"));
         }
         else
         {
             Session["Error"] = model.ProductName + " couldn't be updated please retry!!";
             return(View("Products"));
         }
     }
 }
예제 #7
0
 public bool Update(Products_Model model)
 {
     using (var _context = new SalesTrackingSystemEntities())
     {
         try
         {
             var data = _context.Products.Where(prod => prod.ProductID == model.ProductID).FirstOrDefault();
             data.ProductID         = model.ProductID;
             data.ProductCategoryID = model.ProductCategoryID;
             data.ProductName       = model.ProductName;
             data.PackRate          = model.PackRate;
             data.UnitId            = model.UnitId;
             data.Description       = model.Description;
             data.DateUpdated       = DateTime.Now;
             _context.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
 public ProductDetail_View(Products_Model product)
 {
     NavigationPage.SetHasNavigationBar(this, false);
     InitializeComponent();
     BindingContext = new ProductDetail_ViewModel(Navigation, product);
 }
예제 #9
0
 public PresenteProductDoctro_View(Products_Model product)
 {
     InitializeComponent();
     BindingContext = new PresenteProductDoctor_ViewModel(Navigation, product);
 }