コード例 #1
0
        public async Task <IHttpActionResult> PostGradeDetail(GradeDetail gradeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.GradeDetails.Add(gradeDetail);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (GradeDetailExists(gradeDetail.GradeId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = gradeDetail.GradeId }, gradeDetail));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutGradeDetail(string id, GradeDetail gradeDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gradeDetail.GradeId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public async Task <IHttpActionResult> GetGradeDetail(string id)
        {
            GradeDetail gradeDetail = await db.GradeDetails.FindAsync(id);

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

            return(Ok(gradeDetail));
        }
コード例 #4
0
        public async Task <IHttpActionResult> DeleteGradeDetail(string id)
        {
            GradeDetail gradeDetail = await db.GradeDetails.FindAsync(id);

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

            db.GradeDetails.Remove(gradeDetail);
            await db.SaveChangesAsync();

            return(Ok(gradeDetail));
        }
コード例 #5
0
        public ActionResult SaveGrades(Grade model)
        {
            if (!string.IsNullOrWhiteSpace(model.CourseName))
            {
                String       coursename      = db.Courses.Where(x => x.CourseName == model.CourseName).FirstOrDefault().CourseName;
                var          temp            = db.Enrollments.Where(x => x.CourseName == model.CourseName).ToList();
                List <Grade> objOrder        = new List <Grade>();
                GradeDetail  ObjorderDetails = new GradeDetail();
                foreach (var e in temp)
                {
                    Student myStu = new Student();
                    myStu.StudentEmail = e.StudentEmail;
                    var x = db.Students.Where(xx => xx.StudentEmail == e.StudentEmail).ToList();
                    foreach (var q in x)
                    {
                        myStu.HomeNumber   = q.HomeNumber;
                        myStu.ParentId     = q.ParentId;
                        myStu.Address      = q.Address;
                        myStu.DateOfBirth  = q.DateOfBirth;
                        myStu.DepartmentId = q.DepartmentId;
                        myStu.FatherName   = q.FatherName;
                        myStu.FirstName    = q.FirstName;
                        myStu.LastName     = q.LastName;
                        myStu.Gender       = q.Gender;
                        myStu.StudentId    = q.StudentId;

                        // mymodel.students.Clear();


                        Grade a = new Grade {
                            StudentEmail = myStu.StudentEmail, CourseName = coursename, grade = 0
                        };
                        objOrder.Add(a);
                    }
                }

                ObjorderDetails.Grades = objOrder;
                return(View(ObjorderDetails));
            }
            else
            {
                //  mymodel.students = db.Students.ToList();
            }


            return(View());
        }
コード例 #6
0
        public string InsertUpdateGradeService(GradeDetail gradeDetail)
        {
            var StatusModal = validateModalService.ValidateModalFieldsService <GradeDetail>(gradeDetail);

            if (StatusModal.IsValidModal)
            {
                DbParam[] param = new DbParam[]
                {
                    new DbParam(gradeDetail.GradeUid, typeof(System.String), "_gradeUid"),
                    new DbParam(gradeDetail.Grade, typeof(System.String), "_grade"),
                    new DbParam(gradeDetail.Description, typeof(System.String), "_description"),
                    new DbParam(gradeDetail.MinMarks, typeof(System.Int32), "_minMarks"),
                    new DbParam(gradeDetail.MaxMarks, typeof(System.Int32), "_maxMarks"),
                    new DbParam(userDetail.UserId, typeof(System.String), "_adminUid")
                };
                var Result = db.ExecuteNonQuery("sp_Grade_InsUpd", param, true);
                return(Result);
            }
            return("Incorrect value submitted");
        }
コード例 #7
0
 public ActionResult SaveGrades(GradeDetail GD)
 {
     db.GradeDetails.Add(GD);
     db.SaveChanges();
     return(RedirectToAction("Index", "Home"));
 }
コード例 #8
0
 public IResponse <ApiResponse> AddUpdateGrade([FromBody] GradeDetail gradeDetail)
 {
     this.gradeService.InsertUpdateGradeService(gradeDetail);
     return(GetGrade());
 }