Ejemplo n.º 1
0
        public async Task <IActionResult> PutSearchStd([FromRoute] int id, [FromBody] SearchStd searchStd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != searchStd.SStdID)
            {
                return(BadRequest());
            }

            _context.Entry(searchStd).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SearchStdExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        //private AcaFunctions acaFunctions = new AcaFunctions ();
        //private StdFns stdFns= new StdFns ();

        public ActionResult Index(SearchStd model)
        {
            string searchStr = model.SeaStr;
            IEnumerable <Students> StdDets;

            if (model.SClass == null)
            {
                SearchStd searchStd = new SearchStd
                {
                    SStdID     = 0,
                    SUniReg    = 0,
                    SRegNumber = 0,
                    SStdName   = "",
                    SeaStr     = "",
                    SClass     = "",
                    SGender    = 0,
                    SDOB       = DateTime.Now
                };
                //searchStd.stdList = stdFns.GetStdList(_context, "2016-17", "").Result;
                GetSchClss(_context);
                ViewBag.clsses = StrClsLst;
                //ViewBag.stdList = new SelectList(SchClsLst, "Value", "Text", null);
                return(View(searchStd));
            }
            else
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        ViewBag.sClss = model.SClass;
                        AcaFunctions.GetSchClss(_context);
                        ViewBag.stdList = new SelectList(SchClsLst, "Value", "Text", null);

                        using (HttpClient client = new HttpClient())
                        {
                            client.BaseAddress = new Uri(GloVar.iBaseURI);
                            MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
                            client.DefaultRequestHeaders.Accept.Add(contentType);
                            HttpResponseMessage response = client.GetAsync("/api/SearchStds?SClass=" + model.SClass + "&tSearchStr=" + searchStr + "&dSess=" + dSess + "&mdBID=" + mdBId).Result;  //
                            var stringData = response.Content.ReadAsStringAsync().Result;
                            StdDets = JsonConvert.DeserializeObject <IEnumerable <Students> >(stringData);
                        }

                        ViewBag.datasource = StdDets;
                    }
                    return(View(model));
                }
                catch
                {
                    return(View());
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PostSearchStd([FromBody] SearchStd searchStd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SearchStd.Add(searchStd);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSearchStd", new { id = searchStd.SStdID }, searchStd));
        }