// GET: Master/Vendor
        public async Task <IActionResult> GetVendor()
        {
            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_VENDOR", out List <M_Vendor> c_lstVend))
                {
                    return(Json(new { data = c_lstVend }));
                }

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300),
                    SlidingExpiration = TimeSpan.FromSeconds(60),
                    Priority          = CacheItemPriority.NeverRemove
                };

                using (var vendBll = new VendorBLL())
                {
                    var lstVend = await vendBll.GetVendor(null);

                    _cache.Set("CACHE_MASTER_VENDOR", lstVend, options);

                    return(Json(new { data = lstVend }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }

            //using (var vendBll = new VendorBLL())
            //{
            //    return Json(new { data = await vendBll.GetVendor(null) });
            //}
        }
        public async Task <IActionResult> DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ResultObject resultObj;

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_VENDOR", out List <M_Vendor> c_lstVend))
                {
                    var m_Vendor = c_lstVend.Find(v => v.Id == id);

                    if (m_Vendor == null)
                    {
                        return(NotFound());
                    }

                    m_Vendor.Updated_By = await base.CurrentUserId();

                    using (var vendBll = new VendorBLL())
                    {
                        resultObj = await vendBll.DeleteVendor(m_Vendor);

                        _cache.Remove("CACHE_MASTER_VENDOR");
                    }

                    return(Json(new { success = true, data = (M_Vendor)resultObj.ObjectValue, message = "Vendor Deleted." }));
                }

                using (var vendBll = new VendorBLL())
                {
                    var lstVend = await vendBll.GetVendor(id);

                    var m_Vendor = lstVend.First();

                    if (m_Vendor == null)
                    {
                        return(NotFound());
                    }

                    m_Vendor.Updated_By = await base.CurrentUserId();

                    resultObj = await vendBll.DeleteVendor(m_Vendor);

                    _cache.Remove("CACHE_MASTER_VENDOR");
                }

                return(Json(new { success = true, data = (M_Vendor)resultObj.ObjectValue, message = "Vendor Deleted." }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }));
            }
        }
        // GET: Master/Vendor/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ViewBag.CompCode = await base.CurrentUserComp();

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_VENDOR", out List <M_Vendor> c_lstVend))
                {
                    var m_Vendor = c_lstVend.Find(v => v.Id == id);

                    if (m_Vendor == null)
                    {
                        return(NotFound());
                    }

                    return(PartialView(m_Vendor));
                }

                using (var vendBll = new VendorBLL())
                {
                    var lstVend = await vendBll.GetVendor(id);

                    var m_Vendor = lstVend.First();

                    if (m_Vendor == null)
                    {
                        return(NotFound());
                    }

                    return(PartialView(m_Vendor));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }
        }
Exemple #4
0
        //private void CheckUserAccess()
        //{
        //    if (!ReferenceEquals(Session[Constants.SESSION_USER_INFO], null))
        //    {
        //        IUser user = (IUser)Session[Constants.SESSION_USER_INFO];

        //        if (ReferenceEquals(user, null) || user.Id == 0)
        //        {
        //            Response.Redirect("~/Login.aspx");
        //        }

        //        if (user.UserRole.Id != (int)UserRole.Admin)
        //        {
        //            Response.Redirect("~/Unauthorized.aspx");
        //        }
        //    }
        //    else
        //    {
        //        Response.Redirect("~/Login.aspx");
        //    }
        //}

        private void LoadData()
        {
            VendorEntity oVendor = (VendorEntity)VendorBLL.GetVendor(Convert.ToInt32(hdnVendorID.Value));

            ddlVendorType.SelectedIndex = ddlVendorType.Items.IndexOf(ddlVendorType.Items.FindByValue(oVendor.VendorType));
            if (ddlVendorType.SelectedItem.Text == "CFS/ICD" || ddlVendorType.SelectedItem.Text == "ICD")
            {
                txtCfsCode.Enabled      = true;
                rfvCfdCode.Enabled      = true;
                ddlTerminalCode.Enabled = true;
            }
            else
            {
                txtCfsCode.Enabled      = false;
                rfvCfdCode.Enabled      = false;
                ddlTerminalCode.Enabled = false;
            }
            ddlLocationID.SelectedIndex = Convert.ToInt32(ddlLocationID.Items.IndexOf(ddlLocationID.Items.FindByValue(oVendor.LocationName)));
            PopulateDropDown((int)Enums.DropDownPopulationFor.TerminalCode, ddlTerminalCode, Convert.ToInt32(ddlLocationID.SelectedValue));

            ddlSalutation.SelectedIndex = Convert.ToInt32(ddlSalutation.Items.IndexOf(ddlSalutation.Items.FindByValue(oVendor.VendorSalutation.ToString())));
            if (ddlTerminalCode.Items.Count > 0)
            {
                ddlTerminalCode.SelectedIndex = Convert.ToInt32(ddlTerminalCode.Items.IndexOf(ddlTerminalCode.Items.FindByValue(oVendor.Terminalid.ToString())));
            }

            txtName.Text     = oVendor.VendorName;
            txtAddress.Text  = oVendor.VendorAddress;
            txtCfsCode.Text  = oVendor.CFSCode;
            TxtTAN.Text      = oVendor.TANo;
            TxtPAN.Text      = oVendor.PAN;
            TxtACNo.Text     = oVendor.AcNo;
            TxtAcType.Text   = oVendor.AcType;
            TxtBankName.Text = oVendor.BankName;
            TxtIEC.Text      = oVendor.IEC;
            TxtEmail.Text    = oVendor.EmailID;
            TxtBIN.Text      = oVendor.BIN;
            TxtMob.Text      = oVendor.Mobile;
            TxtCP.Text       = oVendor.CP;
        }
Exemple #5
0
        private void LoadAddress()
        {
            if (!ReferenceEquals(Session[Constants.SESSION_SEARCH_CRITERIA], null))
            {
                SearchCriteria searchCriteria = (SearchCriteria)Session[Constants.SESSION_SEARCH_CRITERIA];

                if (!ReferenceEquals(searchCriteria, null))
                {
                    BuildSearchCriteria(searchCriteria);
                    CommonBLL commonBll = new CommonBLL();

                    gvwVendor.PageIndex = searchCriteria.PageIndex;
                    if (searchCriteria.PageSize > 0)
                    {
                        gvwVendor.PageSize = searchCriteria.PageSize;
                    }

                    gvwVendor.DataSource = VendorBLL.GetVendor(searchCriteria, 0);
                    gvwVendor.DataBind();
                }
            }
        }
        public async Task <IActionResult> GetVendor(string vcode)
        {
            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_VENDOR", out List <M_Vendor> c_lstVend))
                {
                    if (string.IsNullOrEmpty(vcode))
                    {
                        return(Json(new { success = true, data = c_lstVend, message = "Get Vendor Success" }));
                    }
                    else
                    {
                        M_Vendor m_Vendor = c_lstVend.Find(v => v.VendorCode == vcode);

                        if (m_Vendor != null)
                        {
                            return(Json(new { success = true, data = m_Vendor, message = "Get Vendor Success" }));
                        }
                        else
                        {
                            return(Json(new { success = false, data = string.Empty, message = "Vendor Not Found" }));
                        }
                    }
                }

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300),
                    SlidingExpiration = TimeSpan.FromSeconds(60),
                    Priority          = CacheItemPriority.NeverRemove
                };

                using (var vendBll = new VendorBLL())
                {
                    var lstVend = await vendBll.GetVendor(null);

                    _cache.Set("CACHE_MASTER_VENDOR", lstVend, options);

                    if (string.IsNullOrEmpty(vcode))
                    {
                        return(Json(new { success = true, data = lstVend, message = "Get Vendor Success" }));
                    }
                    else
                    {
                        M_Vendor m_Vendor = lstVend.Find(v => v.VendorCode == vcode);

                        if (m_Vendor != null)
                        {
                            return(Json(new { success = true, data = m_Vendor, message = "Get Vendor Success" }));
                        }
                        else
                        {
                            return(Json(new { success = false, data = string.Empty, message = "Vendor Not Found" }));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }
        }