Esempio n. 1
0
        public async Task <ActionResult> GetCategoryById(int id)
        {
            //string strint = id.Trim().ToString();
            //var intid = Convert.ToInt32(strint);
            CategoryMasterModel pro = new CategoryMasterModel();

            CategoryMasterModelSingleRootObject obj = new CategoryMasterModelSingleRootObject();

            string url = GetUrl(2);

            url = url + "Category/GetCategoryById?id=" + Convert.ToInt32(id) + "";
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage responseMessage = await client.GetAsync(url);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var response = responseMessage.Content.ReadAsStringAsync().Result;
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };
                    obj = JsonConvert.DeserializeObject <CategoryMasterModelSingleRootObject>(response, settings);
                    pro = obj.data;
                    TempData["item"] = pro;
                }
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public static CategoryMasterModel CategoryMasterMapper(ta_ussbk_categoryMaster tentity)
 {
     if (tentity != null)
     {
         var resultl = new CategoryMasterModel
         {
             catid   = tentity.catid,
             catname = tentity.catname,
         };
         return(resultl);
     }
     return(null);
 }
Esempio n. 3
0
        public ActionResult GetCategoryInfo(int categoryId)
        {
            //return Json(new { CategoryInformation = NewsIndiaBAL.AdminMethods.GetCategoryInfo(Convert.ToInt32(categoryId)) },
            //    JsonRequestBehavior.AllowGet);
            var categoryInfo        = NewsIndiaBAL.CategoryManager.GetCategoryInfo(categoryId);
            var categoryInformation = new CategoryMasterModel()
            {
                CategoryName = categoryInfo.CategoryName,
                IsVisible    = categoryInfo.IsVisible
            };

            return(Json(new { CategoryInformation = categoryInformation }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create(CategoryMasterModel category)
        {
            var itemCount = await _categoryMasterData.GetDuplicationItemCount(category.CATEGORY_ID);

            if (itemCount > 0)
            {
                ModelState.AddModelError(string.Empty, "This category code already exists.");
                return(View(category));
            }
            await _categoryMasterData.CreateCategory(category);

            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public async Task <string> CreateCategory(CategoryMasterModel category)
        {
            DynamicParameters param = new DynamicParameters();

            param.Add("@categoryId", category.CATEGORY_ID);
            param.Add("@categoryDescr", category.CATEGORY_DESCR);
            param.Add("@abbreviationCode", category.ABBR_CD);

            await _dataAccess.SaveData("dbo.SP_INSERT_CATEGORY_MST",
                                       param,
                                       _connectionString.sqlConnectionName);

            return(param.Get <string>("@categoryId"));
        }
Esempio n. 6
0
 public long Create(CategoryMasterModel tentity)
 {
     using (var scope = new TransactionScope())
     {
         var NewRecord = new ta_ussbk_categoryMaster
         {
             catname = tentity.catname,
         };
         _unitOfWork.CategotyMasterRepository.Insert(NewRecord);
         _unitOfWork.Save();
         scope.Complete();
         return(NewRecord.catid);
     }
 }
Esempio n. 7
0
        public ActionResult Save(CategoryMasterModel input)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                if (input.catid > 0)
                {
                    var result = _mainobj.Update(input.catid, input);
                }
                else
                {
                    var result = _mainobj.Create(input);
                }
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 8
0
        public bool Update(long tid, CategoryMasterModel tentity)
        {
            var success = false;

            if (tentity != null && tid != 0)
            {
                using (var scope = new TransactionScope())
                {
                    var oldrecord = _unitOfWork.CategotyMasterRepository.GetByID(tid);
                    if (oldrecord != null)
                    {
                        oldrecord.catname = tentity.catname;

                        _unitOfWork.CategotyMasterRepository.Update(oldrecord);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
Esempio n. 9
0
        public async Task <ActionResult> AddNewCategory(FormCollection fc, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                ViewBag.StoreId = Session["StoreId"].ToString();
                int    categoryid         = 0;
                string storeid            = "";
                CategoryMasterModel model = new CategoryMasterModel();
                string CategoryId         = fc["CategoryId"];
                string categoryname       = fc["CategoryName"];
                string menuid             = fc["MenuName"];
                if (ViewBag.StoreId == "0")
                {
                    storeid = fc["StoreName"];
                }
                else
                {
                    storeid = ViewBag.StoreId;
                }

                string description = fc["CategoryDescription"];
                string url         = GetUrl(2);
                url = url + "Category/AddNewCategory?CategoryId=" + CategoryId + "&CategoryName=" + categoryname + "&menuid=" + menuid + "&storeid=" + storeid + "&CategoryDescription=" + description + "";

                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage responseMessage = await client.GetAsync(url);

                    CategoryMasterModelSingleRootObject result = new CategoryMasterModelSingleRootObject();
                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var response = responseMessage.Content.ReadAsStringAsync().Result;
                        var settings = new JsonSerializerSettings
                        {
                            NullValueHandling     = NullValueHandling.Ignore,
                            MissingMemberHandling = MissingMemberHandling.Ignore
                        };
                        result = JsonConvert.DeserializeObject <CategoryMasterModelSingleRootObject>(response);
                        if (result.data.CategoryId == 0)
                        {
                            categoryid = Convert.ToInt32(CategoryId);
                        }
                        else
                        {
                            categoryid = result.data.CategoryId;
                        }

                        if (categoryid > 0)
                        {
                            try
                            {
                                var allowedExtensions = new[]
                                {
                                    ".Jpg", ".png", ".jpg", "jpeg", ".JPG",
                                };
                                //string imagepath = "http://103.233.79.234/Data/SJB_Android/CategoryPictures/";
                                model.CategoryPictures = file.ToString();                       //getting complete url
                                var fileName = Path.GetFileName(file.FileName);                 //getting only file name(ex-ganesh.jpg)
                                var ext      = Path.GetExtension(file.FileName);                //getting the extension(ex-.jpg)
                                if (allowedExtensions.Contains(ext))                            //check what type of extension
                                {
                                    string name   = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                                    string myfile = +categoryid + ext;                          //appending the name with id
                                                                                                // store the file inside ~/project folder(Img)
                                                                                                //var path = Path.Combine(imagepath, myfile);
                                    string path = @"C:\inetpub\wwwroot\Data\SJB_Android\CategoryPictures\" + Server.HtmlEncode(myfile);
                                    model.CategoryPictures = path;
                                    //file.SaveAs(path);

                                    var fInfo = new FileInfo(myfile);
                                    if (!fInfo.Exists)
                                    {
                                        file.SaveAs(path);
                                    }
                                    else
                                    {
                                        System.IO.File.Copy(path, path, true);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            ViewBag.message = "Please choose only Image file";
                        }
                    }
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 10
0
        // GET: CategoryMaster
        public async Task <ActionResult> Index()
        {
            ViewBag.LoginID  = Session["LoginID"].ToString();
            ViewBag.Username = Session["Username"].ToString();
            ViewBag.StoreId  = Session["StoreId"].ToString();
            ViewBag.Message  = "Your application Daily Activity page.";
            //return View();
            string preurl = GetUrl(2);

            preurl = preurl + "Store/GetAllStoreList";
            StoreMasterModelRootObject pobj = new StoreMasterModelRootObject();

            //List<ProductMasterModel> Prlist = new List<ProductMasterModel>();
            using (HttpClient prclient = new HttpClient())
            {
                HttpResponseMessage responseMessage = await prclient.GetAsync(preurl);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var result = responseMessage.Content.ReadAsStringAsync().Result;
                    pobj = JsonConvert.DeserializeObject <StoreMasterModelRootObject>(result);
                    IList <SelectListItem> ProSelectList = new List <SelectListItem>();
                    foreach (var item in pobj.data)
                    {
                        ProSelectList.Add(new SelectListItem {
                            Text = item.StoreName, Value = item.StoreId.ToString()
                        });
                    }
                    ProSelectList.Insert(0, new SelectListItem()
                    {
                        Value = "", Text = "Select Store"
                    });
                    //ProSelectList.Insert(1, new SelectListItem() { Value = "0", Text = "All" });
                    ViewBag.StoreList = ProSelectList;
                }
            }

            string murl = GetUrl(2);

            murl = murl + "MenuMaster/GetAllMenuList?StoreId=" + ViewBag.StoreId + "";
            MenuMasterModelRootObject mobj = new MenuMasterModelRootObject();

            //List<MenuMasterModel> mlist = new List<MenuMasterModel>();
            using (HttpClient cclient = new HttpClient())
            {
                HttpResponseMessage responseMessage = await cclient.GetAsync(murl);

                if (responseMessage.IsSuccessStatusCode)
                {
                    var result = responseMessage.Content.ReadAsStringAsync().Result;
                    mobj = JsonConvert.DeserializeObject <MenuMasterModelRootObject>(result);
                    IList <SelectListItem> mSelectList = new List <SelectListItem>();
                    foreach (var item in mobj.data)
                    {
                        mSelectList.Add(new SelectListItem {
                            Text = item.MenuName, Value = item.MenuId.ToString()
                        });
                    }
                    mSelectList.Insert(0, new SelectListItem()
                    {
                        Value = "", Text = "Select Menu"
                    });
                    // mSelectList.Insert(1, new SelectListItem() { Value = "0", Text = "All" });
                    ViewBag.MenuList = mSelectList;
                }
            }
            CategoryMasterModel category = (CategoryMasterModel)TempData["item"];

            return(View(category));
        }
Esempio n. 11
0
        public async Task <IActionResult> Delete(CategoryMasterModel category)
        {
            await _categoryMasterData.DeleteCategory(category.CATEGORY_ID);

            return(RedirectToAction("Index"));
        }