Esempio n. 1
0
        public async Task <List <QueryMasterListModel> > GetUnResolvedQuerysAsync(int customerId = 0)
        {
            List <QueryMasterListModel> list = QueryMasterListModel
                                               .ConvertQueryMasterToListModel(await queryContext.GetUnResolvedQueryOfCustomerAsync(customerId));

            return(list);
        }
Esempio n. 2
0
        public async Task <IActionResult> NewQuery(int id = 0)
        {
            QueryMasterListModel qvm = null;

            if (id == 0)
            {
                ViewData["SubmitBtnTxt"] = "Create Customer";
                qvm            = new QueryMasterListModel();
                qvm.CustomerId = 1;
                qvm.QueryId    = 0;
                qvm.QueryDate  = DateTime.Today;
                qvm.Status     = CustomerQueryData.Models.QueryStatus.New;

                // Retrieve  Products for Drop down
                HttpClient          client = api.Initial();
                HttpResponseMessage res    = await client.GetAsync("api/product/getProducts");

                List <ProductViewModel> pvmList = new List <ProductViewModel>();
                if (res.IsSuccessStatusCode)
                {
                    var result = res.Content.ReadAsStringAsync().Result;
                    pvmList = JsonConvert.DeserializeObject <List <ProductViewModel> >(result);
                }

                ViewData["ProductId"] = new SelectList(pvmList, "ProductId", "Description", qvm.ProductId);
                ViewData["DeptId"]    = new SelectList(await api.PopulateDeptDropDown(), "DeptId", "DeptName", "Select Department");

                return(View(qvm));
            }
            return(View());
        }
Esempio n. 3
0
        public async Task <IActionResult> ViewQuery(int queryId)
        {
            ViewData["Error"] = "";
            // Get Query Master
            // Get All QueryAssigns of the Master
            QueryMasterListModel qVM = null;

            using (HttpClient client = api.Initial())
            {
                using (HttpResponseMessage res = await client.GetAsync("api/query/getQueryDetails/" + queryId))
                {
                    if (res.IsSuccessStatusCode)
                    {
                        var result = res.Content.ReadAsStringAsync().Result;
                        qVM = JsonConvert.DeserializeObject <QueryMasterListModel>(result);
                        if (qVM != null)
                        {
                            if (qVM.QueryAssigns == null)
                            {
                                qVM.QueryAssigns = new List <QueryAssignViewModel>();
                            }
                        }
                        else
                        {
                            ViewData["Error"] = "Not Found: Invalid Query Id";
                        }
                    }
                }
            }

            return(View(qVM));
        }
Esempio n. 4
0
        public async Task <IActionResult> QuerySolution(int queryId)
        {
            QueryAssignViewModel qaVM = new QueryAssignViewModel();

            using (HttpClient client = api.Initial())
            {
                using (HttpResponseMessage res = await client.GetAsync("api/query/getShortQuery/" + queryId))
                {
                    if (res.IsSuccessStatusCode)
                    {
                        var result = res.Content.ReadAsStringAsync().Result;
                        // Need original query to show Question, QryDate, Product Details
                        QueryMasterListModel qVM = JsonConvert.DeserializeObject <QueryMasterListModel>(result);
                        qaVM.QueryId       = queryId;
                        qaVM.ResponseDate  = DateTime.Now;
                        qaVM.FromCustOrEmp = "Emp";
                        qaVM.CustomerId    = qVM.CustomerId;
                        qaVM.CustomerName  = qVM.CustomerName;
                        qaVM.QueryDate     = qVM.QueryDate;
                        qaVM.QueryTitle    = qVM.Title;
                        qaVM.QueryQuestion = qVM.Message;
                        qaVM.Product       = qVM.Product;
                        qaVM.EmployeeId    = 3;
                    }
                }
            }
            return(View(qaVM));
        }
Esempio n. 5
0
        public async Task <List <QueryMasterListModel> > GetUnResolvedQuerysAsync(int deptId = 0)
        {
            List <QueryMasterListModel> list = QueryMasterListModel
                                               .ConvertQueryMasterToListModel(await queryContext.GetUnResolvedQuerysOfDeptAsync(deptId));

            return(list);
        }
Esempio n. 6
0
        public async Task <QueryMasterListModel> GetShortQueryMaster(int queryId)
        {
            QueryMasterListModel qmLM = await GetQueryDetailsAsync(queryId);

            qmLM.QueryAssigns = null;

            return(qmLM);
        }
Esempio n. 7
0
        public async Task <IActionResult> GetRecentResolvedQuerysAsync(int customerId = 0)
        {
            if (customerId <= 0)
            {
                return(BadRequest("Customer ID can't be 0"));    // 400
            }
            List <QueryMasterListModel> list = QueryMasterListModel
                                               .ConvertQueryMasterToListModel(await queryContext.GetRecentResolvedQueryOfCustomerAsync(customerId));

            foreach (QueryMasterListModel qm in list)
            {
                qm.isQuerySolutionRated = await surveyContext.IsQueryRated(qm.QueryId);
            }

            return(Ok(list));
        }
Esempio n. 8
0
        public async Task <QueryMasterListModel> GetQueryDetailsAsync(int queryId)
        {
            if (!queryContext.ExistsQueryId(queryId))
            {
                return(null);
            }

            QueryMaster qm = await queryContext.GetQueryMaster(queryId);

            QueryMasterListModel qlm = QueryMasterListModel.ConvertQueryMasterToListModel(qm);

            // Get if query is Rated by Customer or not
            qlm.isQuerySolutionRated = await queryContext.IsQueryRatedByCustomer(queryId);

            return(qlm);
        }
Esempio n. 9
0
        public async Task <IActionResult> PostNewQueryMaster(QueryMasterListModel queryVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            // CONVERT CustomerModel TO Customer
            QueryMaster qm    = queryVM.ConvertToQueryMaster();
            bool        added = await queryContext.AddNewQuery(qm);

            if (added)
            {
                queryVM.QueryId = qm.QueryId;
                return(CreatedAtAction("PostNewQueryMaster", new { queryId = qm.QueryId }, queryVM));    // new { queryId = qm.QueryId }, queryVM);
            }
            else
            {
                return(BadRequest("Server Error: Failed to add New Query"));
            }
        }
Esempio n. 10
0
        public async Task <IActionResult> NewQuery([Bind("QueryId, CustomerId, ProductId,DeptId, Title,Message,QueryDate,Status")] QueryMasterListModel query)
        {
            string error = "";

            if (ModelState.IsValid)
            {
                if (query.QueryId != 0)
                {
                    return(Unauthorized());  // ("Existing Query cannot be modified");
                }

                using (HttpClient client = api.Initial())
                {
                    // POST
                    using (HttpResponseMessage res = await client.PostAsJsonAsync <QueryMasterListModel>("api/query/newQuery", query))
                    {
                        var result = res.Content.ReadAsStringAsync().Result;
                        if (res.IsSuccessStatusCode)
                        {
                            // To get the Query ID
                            query = JsonConvert.DeserializeObject <QueryMasterListModel>(result);
                            // NEED TO BE ON SAME PAGE & DISPLAY THE QUERY ID
                            ViewData["AlertMsg"] = query.QueryId;
                            return(View("QueryAddedConfirmed"));

                            //return RedirectToAction("Index", "customer");
                        }
                        else
                        {
                            error = res.StatusCode + ": " + res.ReasonPhrase;
                        }
                    }
                }
            }

            //ModelState.AddModelError("Error", error);
            return(View(query));
        }
Esempio n. 11
0
        public async Task <PartialViewResult> ViewQueryAjaxTest(int queryId)
        {
            // Get Query Master
            // Get All QueryAssigns of the Master
            QueryMasterListModel qVM = null;

            using (HttpClient client = api.Initial())
            {
                using (HttpResponseMessage res = await client.GetAsync("api/query/getQueryDetails/" + queryId))
                {
                    if (res.IsSuccessStatusCode)
                    {
                        var result = res.Content.ReadAsStringAsync().Result;
                        qVM = JsonConvert.DeserializeObject <QueryMasterListModel>(result);
                        if (qVM.QueryAssigns == null)
                        {
                            qVM.QueryAssigns = new List <QueryAssignViewModel>();
                        }
                    }
                }
            }

            return(PartialView("ViewQuery", qVM));
        }