Exemplo n.º 1
0
        public IHttpActionResult PutMarksDetail(string id, MarksDetail marksDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != marksDetail.Name)
            {
                return(BadRequest());
            }

            db.Entry(marksDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MarksDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult PostMarksDetail(MarksDetail marksDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MarksDetails.Add(marksDetail);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (MarksDetailExists(marksDetail.Name))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = marksDetail.Name }, marksDetail));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("PkMarksId,FkSemId,FkStudId,FkSubId,SessionalMarks,MainExamMarks,TotalMarks")] MarksDetail marksDetail)
        {
            if (id != marksDetail.PkMarksId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(marksDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MarksDetailExists(marksDetail.PkMarksId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkSemId"]  = new SelectList(_context.MstSemesters, "PkSemId", "PkSemId", marksDetail.FkSemId);
            ViewData["FkStudId"] = new SelectList(_context.StudentDetails, "PkStudentId", "Contact", marksDetail.FkStudId);
            ViewData["FkSubId"]  = new SelectList(_context.MstSubjects, "PkSubjectId", "PkSubjectId", marksDetail.FkSubId);
            return(View(marksDetail));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetMarksDetail(string id)
        {
            MarksDetail marksDetail = db.MarksDetails.Find(id);

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

            return(Ok(marksDetail));
        }
Exemplo n.º 5
0
        public IHttpActionResult DeleteMarksDetail(string id)
        {
            MarksDetail marksDetail = db.MarksDetails.Find(id);

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

            db.MarksDetails.Remove(marksDetail);
            db.SaveChanges();

            return(Ok(marksDetail));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("PkMarksId,FkSemId,FkStudId,FkSubId,SessionalMarks,MainExamMarks,TotalMarks")] MarksDetail marksDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(marksDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FkSemId"]  = new SelectList(_context.MstSemesters, "PkSemId", "PkSemId", marksDetail.FkSemId);
            ViewData["FkStudId"] = new SelectList(_context.StudentDetails, "PkStudentId", "Contact", marksDetail.FkStudId);
            ViewData["FkSubId"]  = new SelectList(_context.MstSubjects, "PkSubjectId", "PkSubjectId", marksDetail.FkSubId);
            return(View(marksDetail));
        }
Exemplo n.º 7
0
        public ActionResult PostMarks(string Name)
        {
            double     objMarks   = 0;
            double     AMarks     = 0;
            var        User       = db.UserDetails.Where(w => w.Name.Equals(Name)).ToList();
            UserDetail userDetail = new UserDetail();

            foreach (var obj in User)
            {
                userDetail.Name       = obj.Name;
                userDetail.Status     = obj.Status;
                userDetail.Email      = obj.Email;
                userDetail.Experience = obj.Experience;
                userDetail.UserId     = obj.UserId;
                userDetail.Phone      = obj.Phone;
            }

            if (userDetail.Status == "Checked")
            {
                return(RedirectToAction("Verify"));
            }

            userDetail.Status = "Checked";

            var         Marks = db.ExamDetails.Where(w => w.Name.Equals(Name)).ToList();
            MarksDetail Data  = new MarksDetail();

            Data.Name = Name;
            foreach (var Mark in Marks)
            {
                AMarks   = AMarks + double.Parse(Mark.AMarks);
                objMarks = objMarks + double.Parse(Mark.Marks);
            }

            Data.AssignedMarks = AMarks;
            Data.TotalMarks    = objMarks;
            Data.Percentage    = (Data.AssignedMarks / Data.TotalMarks) * 100;
            var uri     = "http://localhost:53349/api/MarksDetails/";
            var uri1    = "http://localhost:53349/api/UserDetails/" + userDetail.UserId;
            var json    = JsonConvert.SerializeObject(Data);
            var request = new StringContent(json.ToString(), Encoding.UTF8, "application/json");

            request.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var json1    = JsonConvert.SerializeObject(userDetail);
            var request1 = new StringContent(json1.ToString(), Encoding.UTF8, "application/json");

            request1.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            using (HttpClient obj = new HttpClient())
            {
                obj.Timeout = TimeSpan.FromMilliseconds(15000);
                obj.MaxResponseContentBufferSize = 256000;
                //var response = obj.PostAsync(uri, request).Result;
                HttpResponseMessage response  = null;
                HttpResponseMessage response1 = null;
                try
                {
                    response  = obj.PostAsync(uri, request).Result;
                    response1 = obj.PutAsync(uri1, request1).Result;
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                if (response.IsSuccessStatusCode && response1.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Verify"));
                }
                throw new Exception(response.ReasonPhrase);
            }
        }