Beispiel #1
0
        public async Task <ActionResult> Index()
        {
            WebAPI webapi = new WebAPI();
            HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Get, "APICategory", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]));

            if (response.IsSuccessStatusCode)
            {
                //get the headers values
                HttpHeaders          headers = response.Headers;
                IEnumerable <string> values;
                if (headers.TryGetValues("PageNo", out values))
                {
                    string session = values.First();
                }

                // get the content values
                var data = await response.Content.ReadAsStringAsync();

                // to convert json  in data table
                //var table = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Data.DataTable>(data);

                // convert json in IEnumerable object list of category
                var categories = JsonConvert.DeserializeObject <IEnumerable <Category> >(data);

                return(View(categories));
            }
            else
            {
                return(View());
            }
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(int id)
        {
            WebAPI webapi = new WebAPI();
            HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Get, "APICategory", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), id.ToString());

            if (response.IsSuccessStatusCode)
            {
                var data = await response.Content.ReadAsStringAsync();

                // to convert json  in data table
                //var table = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Data.DataTable>(data);

                // convert json in IEnumerable object list of category
                var categories = JsonConvert.DeserializeObject <Category>(data);

                return(View(categories));
            }
            else
            {
                return(View());
            }

            //CategoryBL categroyBL = new CategoryBL();
            //var categories = categroyBL.GetCategoryById(id);
            //return View(categories);
        }
Beispiel #3
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            ReturnResult returnResult = new ReturnResult();
            Category     objCategory  = new Category();

            try
            {
                // TODO: Add insert logic here
                objCategory.categoryid   = 0;
                objCategory.CategoryCode = Convert.ToString(collection["CategoryCode"]);
                objCategory.CategoryName = Convert.ToString(collection["CategoryName"]);
                objCategory.Description  = Convert.ToString(collection["Description"]);

                WebAPI webapi = new WebAPI();
                HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Post, "APICategory", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), "0", objCategory);

                if (response.IsSuccessStatusCode)
                {
                    var data = await response.Content.ReadAsStringAsync();

                    // convert json in IEnumerable object list of category
                    returnResult = JsonConvert.DeserializeObject <ReturnResult>(data);

                    if (returnResult.IsSuccess)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["CreateCategoryMessage"] = returnResult.Message;
                        return(View(objCategory));
                    }
                }
                else
                {
                    TempData["CreateCategoryMessage"] = "Error while saving data.";
                    return(View(objCategory));
                }

                // CategoryBL categroyBL = new CategoryBL();

                // returnResult= categroyBL.SaveCategory(objCategory);
                //if (returnResult.IsSuccess)
                //{
                //    return RedirectToAction("Index");
                //}
                // else
                //{
                //    TempData["CreateCategoryMessage"] = returnResult.Message;
                //    return View(objCategory);
                //}
            }
            catch
            {
                TempData["CreateCategoryMessage"] = returnResult.Message;
                return(View(objCategory));
            }
        }
        public async Task <ActionResult> Create(FormCollection collection)
        {
            ReturnResult  returnResult = new ReturnResult();
            CompanyMaster objCompany   = new CompanyMaster();

            try
            {
                // TODO: Add insert logic here

                CompanyBL objcompanyBL = new CompanyBL();
                objCompany.CompanyId      = 0;
                objCompany.CompanyCode    = Convert.ToString(collection["CompanyCode"]);
                objCompany.CompanyName    = Convert.ToString(collection["CompanyName"]);
                objCompany.Address        = Convert.ToString(collection["Address"]);
                objCompany.City           = Convert.ToString(collection["City"]);
                objCompany.ContactEmail   = Convert.ToString(collection["City"]);
                objCompany.OwnedBy        = Convert.ToString(collection["OwnedBy"]);
                objCompany.Phone1         = Convert.ToString(collection["Phone1"]);
                objCompany.Phone2         = Convert.ToString(collection["Phone2"]);
                objCompany.RegistrationNo = Convert.ToString(collection["RegistrationNo"]);
                objCompany.Tin            = Convert.ToString(collection["Tin"]);
                objCompany.Website        = Convert.ToString(collection["Website"]);

                WebAPI webapi = new WebAPI();
                HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Post, "APICompany", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), "0", objCompany);

                if (response.IsSuccessStatusCode)
                {
                    var data = await response.Content.ReadAsStringAsync();

                    // convert json in IEnumerable object list of category
                    returnResult = JsonConvert.DeserializeObject <ReturnResult>(data);

                    if (returnResult.IsSuccess)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["CreateCompanyMessage"] = returnResult.Message;
                        return(View(objCompany));
                    }
                }
                else
                {
                    TempData["CreateCompanyMessage"] = "Error while saving data.";
                    return(View(objCompany));
                }
            }
            catch
            {
                TempData["CreateCompanyMessage"] = returnResult.Message;
                return(View(objCompany));
            }
        }
Beispiel #5
0
        // GET: Employee

        public async Task <JsonResult> GetEmployees(int jtStartIndex, int jtPageSize, string EMPCode, string FirstName)
        {
            int totalRows = 0;

            jtStartIndex = jtStartIndex == 0 ? 0 : (jtStartIndex / jtPageSize + 1);

            Paging objpaging = new Paging
            {
                MaxRows       = jtPageSize,
                Order         = "DESC",
                OrderBy       = "EmployeeID",
                StartRowIndex = jtStartIndex
            };

            EmployeeMaster objEmployee = new EmployeeMaster()
            {
                EmpCode = EMPCode, FirstName = FirstName
            };
            // Currently we are passing two objects 1. customer and Paging , if we need to pass more objects other than Paging then we need to wrap those objects and passed.
            //same like  we are passing wraping objects in webapi (WebAPIPassingClass)
            WebAPI webapi = new WebAPI();
            HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Post, "APIEmployee", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), "0", objEmployee, objpaging);

            if (response.IsSuccessStatusCode)
            {
                //get the headers values
                HttpHeaders          headers = response.Headers;
                IEnumerable <string> values;
                if (headers.TryGetValues("TotalRows", out values))
                {
                    totalRows = Convert.ToInt32(values.First());
                }

                // get the content values
                var data = await response.Content.ReadAsStringAsync();

                // convert json in IEnumerable object list of CustomerMaster
                var employeeList = JsonConvert.DeserializeObject <IEnumerable <EmployeeMaster> >(data);

                try
                {
                    return(Json(new { Result = "OK", Records = employeeList, TotalRecordCount = totalRows }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { Result = "ERROR", Message = ex.Message }));
                }
            }
            else
            {
                TempData["CreateEmployeeMessage"] = "Error while saving data.";
                return(null);
            }
        }
Beispiel #6
0
        public async Task <ActionResult> Edit(int id, FormCollection collection)
        {
            ReturnResult returnResult = new ReturnResult();
            Category     objCategory  = new Category();

            try
            {
                // Just to check the error log
                //int a = 0, b=1,c;
                //c = b / a;


                CategoryBL categoryBL = new CategoryBL();
                objCategory.categoryid   = id;
                objCategory.CategoryCode = Convert.ToString(collection["CategoryCode"]);
                objCategory.CategoryName = Convert.ToString(collection["CategoryName"]);
                objCategory.Description  = Convert.ToString(collection["Description"]);
                //returnResult=categoryBL.SaveCategory(objCategory);

                WebAPI webapi = new WebAPI();
                HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Put, "APICategory", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), id.ToString(), objCategory);

                if (response.IsSuccessStatusCode)
                {
                    var data = await response.Content.ReadAsStringAsync();

                    // convert json in IEnumerable object list of category
                    returnResult = JsonConvert.DeserializeObject <ReturnResult>(data);

                    if (returnResult.IsSuccess)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["UpdateCategoryMessage"] = returnResult.Message;
                        return(View(objCategory));
                    }
                }
                else
                {
                    TempData["UpdateCategoryMessage"] = "Error while saving data.";
                    return(View(objCategory));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("IBS.ERP.Controllers.Edit [HttpPost] ID: " + id, ex);
                TempData["UpdateCategoryMessage"] = returnResult.Message;
                return(View(objCategory));
            }
        }
Beispiel #7
0
        public async Task <ActionResult> Delete(int id)
        {
            WebAPI webapi = new WebAPI();
            HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Delete, "APICategory", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), id.ToString());

            if (response.IsSuccessStatusCode)
            {
                var data = await response.Content.ReadAsStringAsync();

                // convert json in IEnumerable object list of category
                ReturnResult returnResult = JsonConvert.DeserializeObject <ReturnResult>(data);

                if (returnResult.IsSuccess)
                {
                    TempData["Message"] = "Category deleted successfully.";// returnResult.Message;//
                }
                else
                {
                    TempData["Message"] = "Error while deleting category.";// = returnResult.Message;
                }
            }
            else
            {
                TempData["Message"] = "Error while deleting category.";
            }


            // CategoryBL categoryBL = new CategoryBL();
            //ReturnResult result= categoryBL.DeleteCategory(id);
            //if (!result.IsSuccess)
            //{
            //    TempData["Message"] = "Error while deleting category.";
            //}

            return(RedirectToAction("Index"));
            //return View();
        }
        public async Task <ActionResult> Index()
        {
            // get the search fields
            WebAPI webapi = new WebAPI();
            HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Get, "APILookup", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), "CustomerSearch");

            if (response.IsSuccessStatusCode)
            {
                // get the content values
                var data = await response.Content.ReadAsStringAsync();

                // convert json in IEnumerable object list of CustomerMaster
                var lookupList = JsonConvert.DeserializeObject <IEnumerable <Lookup> >(data);


                //using viewbag
                ViewData["FieldDropdown"] = new SelectList(lookupList.ToList(), "Code", "Text");
                return(View(lookupList));
            }
            else
            {
                return(View());
            }
        }
        //public async Task<JsonResult> GetStudentMarks(int jtStartIndex, int jtPageSize, string CompanyName, string CustomerCode, string ContactName, string Phone, string City, string State, string Country, string FromDate, string ToDate, string PostalCode)
        public async Task <JsonResult> GetGridData(int jtStartIndex, int jtPageSize, string searchField1, string searchField1Value, string searchField2, string searchField2Value, string condition)
        {
            try
            {
                int  totalRows = 0;
                bool blnCreate = false, blnEdit = false, blnDelete = false, blnView = false;

                jtStartIndex = jtStartIndex == 0 ? 0 : (jtStartIndex / jtPageSize + 1);

                Paging objpaging = new Paging
                {
                    MaxRows       = jtPageSize,
                    Order         = "DESC",
                    OrderBy       = "Partnerid",
                    StartRowIndex = jtStartIndex,
                    //FromDate = FromDate,
                    //ToDate=ToDate
                };

                Search objSearch = new Search()
                {
                    SearchField1 = searchField1, SearchField1Value = searchField1Value, SearchField2 = searchField2, SearchField2Value = searchField2Value, Condition = condition, SearchOn = "Customer"
                };
                // Currently we are passing two objects 1. customer and Paging , if we need to pass more objects other than Paging then we need to wrap those objects and passed.
                //same like  we are passing wraping objects in webapi (WebAPIPassingClass)
                WebAPI webapi = new WebAPI();
                HttpResponseMessage response = await webapi.CallToWebAPI(APICallType.Post, "APIPartners", "", Convert.ToString(Session["DBConnectionString"]), Convert.ToString(Session["UserAccount"]), Convert.ToString(Session["RoleId"]), Convert.ToString(Session["CompanyCode"]), "0", objSearch, objpaging);

                if (response.IsSuccessStatusCode)
                {
                    //get the headers values
                    HttpHeaders          headers = response.Headers;
                    IEnumerable <string> values;
                    if (headers.TryGetValues("TotalRows", out values))
                    {
                        totalRows = Convert.ToInt32(values.First());
                    }

                    if (headers.TryGetValues("CreatePermission", out values))
                    {
                        blnCreate = Convert.ToBoolean(values.First());
                    }

                    if (headers.TryGetValues("UpdatePermission", out values))
                    {
                        blnEdit = Convert.ToBoolean(values.First());
                    }

                    if (headers.TryGetValues("DeletePermission", out values))
                    {
                        blnDelete = Convert.ToBoolean(values.First());
                    }

                    if (headers.TryGetValues("ViewPermission", out values))
                    {
                        blnView = Convert.ToBoolean(values.First());
                    }

                    // get the content values
                    var data = await response.Content.ReadAsStringAsync();

                    // convert json in IEnumerable object list of CustomerMaster
                    var customerList = JsonConvert.DeserializeObject <IEnumerable <CustomerMaster> >(data);

                    return(Json(new { Result = "OK", Records = customerList, TotalRecordCount = totalRows, createPermission = blnCreate, updatePermission = blnEdit, deletePermission = blnDelete, viewPermission = blnView }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    TempData["CustomerErrorMessage"] = "Error while retrieving data.";
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("IBS.ERP.CustomerController.GetGridData", ex);
                TempData["CustomerErrorMessage"] = "Error while retrieving data.";
                return(null); //return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }