Beispiel #1
0
        public JsonResult SaveDataInDatabase(ProductTypeVM model)
        {
            var result = false;

            try
            {
                if (model.IDProductType > 0)
                {
                    ProductType Pro = db.ProductTypes.SingleOrDefault(x => x.IDProductType == model.IDProductType);
                    Pro.NameProductType = model.NameProductType;
                    Pro.Icon            = model.Icon;
                    Pro.Alias           = model.Alias;

                    db.SaveChanges();
                    result = true;
                }
                else
                {
                    ProductType Pro = new ProductType();
                    Pro.NameProductType = model.NameProductType;
                    Pro.Icon            = model.Icon;
                    Pro.Alias           = model.Alias;

                    db.ProductTypes.Add(Pro);
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(ProductTypeVM v)
        {
            ProductType a = new ProductType();

            if (ModelState.IsValid)
            {
                int max = (from c in db.ProductTypes orderby c.ProductTypeID descending select c.ProductTypeID).FirstOrDefault();
                a.ProductTypeID = max + 1;
                a.ProductName   = v.ProductName;

                a.ParcelTypeID = v.ParcelType;

                a.TransportModeID = v.TransportModeID;
                a.CBMBasedCharges = v.CBMbasedCharges;
                a.Length          = v.Length;
                a.Width           = v.Width;
                a.Height          = v.Height;
                a.CBM             = v.CBM;
                db.ProductTypes.Add(a);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added Product Type.";
                return(RedirectToAction("Index"));
            }

            return(View(v));
        }
        public ActionResult Edit(int id = 0)
        {
            ViewBag.ParcelType = db.ParcelTypes.ToList();

            ViewBag.transport = db.TransportModes.ToList();

            ProductTypeVM v = new ProductTypeVM();
            ProductType   a = (from c in db.ProductTypes where c.ProductTypeID == id select c).FirstOrDefault();

            if (a == null)
            {
                return(HttpNotFound());
            }
            else
            {
                v.ProductTypeID = a.ProductTypeID;
                v.ProductName   = a.ProductName;

                v.ParcelType = a.ParcelTypeID;

                v.TransportModeID = a.TransportModeID;
                v.CBMbasedCharges = a.CBMBasedCharges;
                v.Length          = a.Length.Value;
                v.Width           = a.Width.Value;
                v.Height          = a.Height.Value;
                v.CBM             = a.CBM.Value;
            }
            return(View(v));
        }
        public ActionResult Edit(ProductTypeVM a)
        {
            if (ModelState.IsValid)
            {
                ProductType v = new ProductType();

                v.ProductTypeID = a.ProductTypeID;
                v.ProductName   = a.ProductName;

                v.ParcelTypeID = a.ParcelType;

                v.TransportModeID = a.TransportModeID;
                v.CBMBasedCharges = a.CBMbasedCharges;
                v.Length          = a.Length;
                v.Width           = a.Width;
                v.Height          = a.Height;
                v.CBM             = a.CBM;

                db.Entry(v).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Updated Product Type.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Beispiel #5
0
        private void dataGridbind()
        {
            try
            {
                _entities = new KBBQEntities();

                List <ProductTypeVM> modelList = new List <ProductTypeVM>();

                var data = _entities.tblProTypes.OrderBy(x => x.proSubCate).ToList();


                int rowNo = 1;
                foreach (var item in data)
                {
                    ProductTypeVM model = new ProductTypeVM();
                    model.prodTypeName = item.prodTypeName;
                    model.proSubCate   = item.proSubCate;
                    model.proTypeID    = item.proTypeID;

                    model.rowNo = rowNo;

                    modelList.Add(model);
                    rowNo++;
                }
                lblTotalRecord.Text      = modelList.Count.ToString();
                dataGridView1.DataSource = modelList;
            }
            catch (Exception x)
            {
            }
        }
Beispiel #6
0
        // Number of images in folder
        public static int ReturnImageLength(ProductTypeVM type)
        {
            string path = String.Format(@"C:\Users\vikto\source\repos\Prof_Projects\Asp.NetCore_IdealDesign\Asp.NetCore_IdealDesign\wwwroot\images\Ideal_galery\{0}\", type);

            string[] directoryPath = Directory.GetFiles(path, "*.jpg");
            return(directoryPath.Length);
        }
Beispiel #7
0
        private ProductTypeVM BuildProductType()
        {
            ProductTypeVM productType = new ProductTypeVM();

            productType.Name = _name.Text.Trim();
            productType.Tags = GetSelectedTags();

            return(productType);
        }
Beispiel #8
0
        public IActionResult ProductTypeDashboard()
        {
            List <ProductType> dbResult = dbContext.ProductTypes.ToList();

            ProductTypeVM model = new ProductTypeVM();

            model.ProductTypes = dbResult;

            return(View(model));
        }
Beispiel #9
0
        public IActionResult ProductType(ProductTypeVM type)
        {
            try
            {
                switch (type)
                {
                case ProductTypeVM.Kitchens:
                    ViewBag.type = _localizer[ServiceHelper.GetDescription(ProductTypeVM.Kitchens)];
                    break;

                case ProductTypeVM.Wardrobes:
                    ViewBag.type = _localizer[ServiceHelper.GetDescription(ProductTypeVM.Wardrobes)];
                    break;

                case ProductTypeVM.BathroomFurniture:
                    ViewBag.type = _localizer[ServiceHelper.GetDescription(ProductTypeVM.BathroomFurniture)];
                    break;

                case ProductTypeVM.LivingRoomFurniture:
                    ViewBag.type = _localizer[ServiceHelper.GetDescription(ProductTypeVM.LivingRoomFurniture)];
                    break;

                case ProductTypeVM.WallBeds:
                    ViewBag.type =
                        _localizer[ServiceHelper.GetDescription(ProductTypeVM.WallBeds)];
                    break;

                case ProductTypeVM.ChildrensFurniture:
                    ViewBag.type = ServiceHelper.GetDescription(ProductTypeVM.ChildrensFurniture);
                    break;

                case ProductTypeVM.Other:
                    ViewBag.type = _localizer[ServiceHelper.GetDescription(ProductTypeVM.Other)];
                    break;

                default:
                    RedirectToAction("Product/ProductType?type=Kitchens");
                    break;
                }

                ViewBag.imgLength   = ServiceHelper.ReturnImageLength(type);
                ViewBag.productType = type;
                var products = _productService.GetProductByType((ProductTypes)type).ToList();
                return(View(products));
            }
            catch (Exception ex)
            {
                Log.Error($"{ex.Message}");
            }
            return(PartialView("ErrorView"));
        }
        public ActionResult Index()
        {
            List <ProductTypeVM> lst = new List <ProductTypeVM>();
            var data = (from c in db.ProductTypes select c).ToList();

            foreach (var item in data)
            {
                ProductTypeVM v = new ProductTypeVM();
                v.ProductTypeID = item.ProductTypeID;
                v.ProductName   = item.ProductName;

                lst.Add(v);
            }
            return(View(lst));
        }
Beispiel #11
0
        private void ProductTypeSelected(object sender, EventArgs e)
        {
            try
            {
                ProductTypeVM type = (ProductTypeVM)_productype.SelectedItem;

                List <ProductVM> products = _productDao.GetProducts(type);

                LoadGrid(products);
            }
            catch (HttpException ex)
            {
                MessageBox.Show(ex.Message, "Ocurrio un error en el servidor");
            }
        }
Beispiel #12
0
        public IActionResult NewProductType(ProductType form)
        {
            if (ModelState.IsValid)
            {
                dbContext.ProductTypes.Add(form);
                dbContext.SaveChanges();
                return(RedirectToAction("ProductTypeDashboard"));
            }

            List <ProductType> dbResult = dbContext.ProductTypes.ToList();
            ProductTypeVM      model    = new ProductTypeVM();

            model.ProductTypes = dbResult;

            return(View("ProductTypeDashboard", model));
        }
Beispiel #13
0
        private void txtCategory_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (txtCategory.Text != string.Empty)
                {
                    _entities = new KBBQEntities();

                    List <ProductTypeVM> modelList = new List <ProductTypeVM>();

                    var data = _entities.tblProTypes.Where(x => x.proSubCate.Contains(txtCategory.Text.Trim().ToString())).OrderBy(x => x.proSubCate).ToList();


                    int rowNo = 1;
                    foreach (var item in data)
                    {
                        ProductTypeVM model = new ProductTypeVM();
                        model.prodTypeName = item.prodTypeName;
                        model.proSubCate   = item.proSubCate;
                        model.proTypeID    = item.proTypeID;

                        model.rowNo = rowNo;

                        modelList.Add(model);
                        rowNo++;
                    }
                    lblTotalRecord.Text      = modelList.Count.ToString();
                    dataGridView1.DataSource = modelList;
                }
                else
                {
                    dataGridbind();
                }
            }
            catch (Exception x)
            {
            }
        }
Beispiel #14
0
        public List <ProductVM> GetProducts(ProductTypeVM type)
        {
            var response = _requestHandler.Request <List <ProductVM> >(RequestPaths.ProductListBy, type.Id.ToString(), Method.GET);

            return(response.Content);
        }
Beispiel #15
0
 public void AddProductType(ProductTypeVM productType)
 {
     _requestHandler.Request(RequestPaths.AddProductType, Method.POST, productType);
 }