public ActionResult Brands()
        {
            ShopM        shop = new ShopM();
            List <Brand> lst  = shop.Brand.ToList();

            return(View(lst));
        }
        public ActionResult CompanyInfo()
        {
            ShopM   shop  = new ShopM();
            Company exist = shop.Company.Where(c => c.lang == "EN").FirstOrDefault();

            return(View(exist));
        }
        public JsonResult getSubcategoryByCategory(int catgId) //It will be fired from Jquery ajax call
        {
            ShopM shop     = new ShopM();
            var   jsonData = shop.SubCategory.Where(c => c.cat_id == catgId).ToList();

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CompanyInfo(string txtcompanyName, string txtphone, string txtphone2, string txtAddress, string txtEmail, string txtAbout)
        {
            ShopM   shop  = new ShopM();
            Company exist = shop.Company.Where(c => c.lang == "EN").FirstOrDefault();

            if (exist != null)
            {
                exist.address           = txtAddress;
                exist.brief_discription = txtAbout;
                exist.company_name      = txtcompanyName;
                exist.mail   = txtEmail;
                exist.phone  = txtphone;
                exist.mobile = txtphone2;
            }
            else
            {
                Company newcomp = new Company();
                newcomp.address           = txtAddress;
                newcomp.brief_discription = txtAbout;
                newcomp.company_name      = txtcompanyName;
                newcomp.mail   = txtEmail;
                newcomp.phone  = txtphone;
                newcomp.mobile = txtphone2;
                newcomp.lang   = "EN";
                shop.Company.Add(newcomp);
            }
            shop.SaveChanges();
            exist = shop.Company.Where(c => c.lang == "EN").FirstOrDefault();
            return(View(exist));
        }
        public ActionResult Category()
        {
            ShopM           shop = new ShopM();
            List <Category> lst  = shop.Category.ToList();

            return(View(lst));
        }
        public ActionResult Category(string categoryName, HttpPostedFileBase inpImage)
        {
            try
            {
                ShopM shop = new ShopM();

                shop.Category.Add(new DataModel.Category {
                    cat_name = categoryName, del_flag = false, modify_user_id = 0, lang = "EN"
                });
                shop.SaveChanges();
                List <Category> lst = shop.Category.ToList();

                return(View(lst));
            }
            catch (DbEntityValidationException dbEx)
            {
                //code for get validation error (column name ,and error)
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
                return(View());
            }
        }
        public ActionResult SubCategory()
        {
            ShopM           shop = new ShopM();
            List <Category> lst  = shop.Category.ToList();

            ViewBag.catg = lst;
            return(View());
        }
        public PartialViewResult _SubCategoryList()
        {
            ShopM           shop = new ShopM();
            List <Category> lst  = shop.Category.Where(c => c.id > 3).ToList();

            ViewBag.catg = lst;
            return(PartialView());
        }
        public ActionResult Save(ShopM shop)
        {
            if (ModelState.IsValid)
            {
                shopService.Edit(shop);
            }

            return(RedirectToAction("Info"));
        }
        public ActionResult editCategory(int catId, string editCategoryName, HttpPostedFileBase inpImageEdit)
        {
            ShopM    shop = new ShopM();
            Category cat  = shop.Category.Where(c => c.id == catId).FirstOrDefault();

            cat.cat_name = editCategoryName;
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            return(View("Category", lst));
        }
        public ActionResult editBrand(int brandId, string editBrandName)
        {
            ShopM shop = new ShopM();
            Brand bran = shop.Brand.Where(c => c.id == brandId).FirstOrDefault();

            bran.brand_name = editBrandName;
            shop.SaveChanges();
            List <Brand> lst = shop.Brand.ToList();

            return(View("Brands", lst));
        }
        public ActionResult deleteCategory(int catId)
        {
            ShopM    shop = new ShopM();
            Category cat  = shop.Category.Where(c => c.id == catId).FirstOrDefault();

            cat.del_flag = true;
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            Category();
            return(View("Category", lst));
        }
        public ActionResult Brands(string txtBrandName)
        {
            ShopM shop = new ShopM();

            shop.Brand.Add(new DataModel.Brand {
                brand_name = txtBrandName, del_flag = false
            });
            shop.SaveChanges();
            List <Brand> lst = shop.Brand.ToList();

            return(View(lst));
        }
        public ActionResult deleteBrand(int Brand)
        {
            ShopM shop = new ShopM();
            Brand bran = shop.Brand.Where(c => c.id == Brand).FirstOrDefault();

            bran.del_flag = true;
            shop.SaveChanges();
            List <Brand> lst = shop.Brand.ToList();

            Category();
            return(View("Brands", lst));
        }
        public ActionResult deleteSubcategory(int subId)
        {
            ShopM       shop = new ShopM();
            SubCategory sub  = shop.SubCategory.Where(c => c.id == subId).FirstOrDefault();

            sub.del_flag = true;
            shop.SaveChanges();
            List <Category> lst = shop.Category.Where(c => c.id > 3).ToList();

            ViewBag.catg = lst;
            return(View("SubCategory"));
        }
Beispiel #16
0
        public ActionResult Info()
        {
            CustomerM customer = authService.DecodeJWT(User.Identity.Name);

            ShopM shop = new ShopM();

            if (customer.ShopAdminId != -1)
            {
                shop = shopService.FindById(customer.ShopAdminId);
            }

            return(View(shop));
        }
        public ActionResult editSubcategory(int subId, string editSubcategoryName, int ddlCategForEdit)
        {
            ShopM       shop = new ShopM();
            SubCategory catg = shop.SubCategory.Where(c => c.id == subId).FirstOrDefault();

            catg.sub_cat_name = editSubcategoryName;
            catg.cat_id       = ddlCategForEdit;
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            ViewBag.catg = lst;
            return(View("SubCategory"));
        }
        public ActionResult SubCategory(string txtSubcategoryName, int ddlCategForAdd)
        {
            ShopM shop = new ShopM();

            shop.SubCategory.Add(new DataModel.SubCategory {
                sub_cat_name = txtSubcategoryName, del_flag = false, cat_id = ddlCategForAdd, modify_user_id = 0, lang = "EN"
            });
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            ViewBag.catg = lst;
            return(View());
        }
Beispiel #19
0
        public ShopM Save(ShopM shop)
        {
            Shop shopDb = new Shop()
            {
                ContactAddress     = shop.ContactAddress,
                ContactMobilePhone = shop.ContactMobilePhone,
                ContactPhone       = shop.ContactPhone,
                HirePayment        = shop.HirePayment,
                OpenTime           = shop.OpenTime,
                ShopName           = shop.ShopName,
            };

            Context.Shops.Add(shopDb);
            Context.SaveChanges();
            shop.Id = shopDb.Id;
            return(shop);
        }
Beispiel #20
0
        public ActionResult Add(ShoppingM shopping)
        {
            MobileM      mobile      = mobileService.FindById(shopping.MobileId);
            ShopM        shop        = shopService.FindById(shopping.ShopId);
            CustomerM    customer    = authService.DecodeJWT(User.Identity.Name);
            ShopMobilesM shopMobiles = shopMobilesService.FindByShopAndMobile(shop.Id, mobile.Id);

            if (!ModelState.IsValid || mobile == null || shop == null ||
                customer == null || shopMobiles == null || shopping.Price != shopMobiles.Price)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            shopping.CustomerId = customer.Id;
            shopping.Status     = "Active";
            shoppingService.Save(shopping);

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Beispiel #21
0
        public ShopM Edit(ShopM shop)
        {
            var found = Context.Shops.SingleOrDefault(x => x.Id == shop.Id);

            if (found == null)
            {
                return(null);
            }
            found.ShopName           = shop.ShopName;
            found.OpenTime           = shop.OpenTime;
            found.ContactPhone       = shop.ContactPhone;
            found.ContactMobilePhone = shop.ContactMobilePhone;
            found.ContactAddress     = shop.ContactAddress;
            found.HirePayment        = shop.HirePayment;
            Context.SaveChanges();

            return(shop);
        }
Beispiel #22
0
        public ActionResult Create(ShopM shop)
        {
            if (ModelState.IsValid)
            {
                CustomerM customer = authService.DecodeJWT(User.Identity.Name);
                if (customer.ShopAdminId != -1)
                {
                    return(RedirectToAction("New"));
                }
                shop                 = shopService.Save(shop);
                customer.IsAdmin     = true;
                customer.ShopAdminId = shop.Id;
                customerService.Edit(customer);
                HttpContext.Response.SetCookie(new HttpCookie("Role", "ADMIN"));
            }

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #23
0
        public ActionResult History()
        {
            CustomerM          admin     = authService.DecodeJWT(User.Identity.Name);
            ShopM              shop      = shopService.FindById(admin.ShopAdminId);
            List <ShoppingDTO> shoppings = new List <ShoppingDTO>();

            foreach (var shopping in shoppingService.FindAll().Where(x => x.ShopId == shop.Id))
            {
                shoppings.Add(new ShoppingDTO()
                {
                    Id         = shopping.Id,
                    Customer   = admin.Email,
                    CustomerId = admin.Id,
                    MobileId   = shopping.MobileId,
                    MobileName = mobileService.FindById(shopping.MobileId).Name,
                    Price      = shopping.Price,
                    Status     = shopping.Status,
                });
            }


            return(View(shoppings));
        }
Beispiel #24
0
 public ShopM Save(ShopM shop)
 {
     return(shopRepository.Save(shop));
 }
Beispiel #25
0
 public ShopM Edit(ShopM shop)
 {
     return(shopRepository.Edit(shop));
 }