Exemplo n.º 1
0
        public JsonReturnModel getAttendence(StudentAttendence StudentAttendence)
        {
            List <AttendenceModel> attendenceList = new List <AttendenceModel>();
            var Customer = _CustomerService.GetCustomer(StudentAttendence.CustomerId).CustomerType;

            if (Customer != null)
            {
                if (Customer == StudentAttendence.CustomerType)
                {
                    if (Customer == EnumValue.GetEnumDescription(EnumValue.CustomerType.Student) || Customer == EnumValue.GetEnumDescription(EnumValue.CustomerType.Parent))
                    {
                        var attendences = _AttendenceService.GetAttendences().Where(a => (a.AttendenceDate >= StudentAttendence.StartDate && a.AttendenceDate <= StudentAttendence.EndDate) && a.CustomerId == StudentAttendence.CustomerId).ToList();
                        if (attendences.Count() > 0)
                        {
                            foreach (var item in attendences)
                            {
                                if (item.Status == EnumValue.GetEnumDescription(EnumValue.AttendenceStatus.Present))
                                {
                                    Mapper.CreateMap <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>();
                                    Onlo.Models.AttendenceModel Attendence = Mapper.Map <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>(item);
                                    attendenceList.Add(Attendence);
                                }
                            }
                        }
                    }
                    else
                    {
                        var CustomerList = _CustomerService.GetCustomers().Where(c => c.ParentId == StudentAttendence.CustomerId).ToList();
                        if (CustomerList.Count() > 0)
                        {
                            var CustomerIds = CustomerList.Select(s => s.CustomerId).ToList();
                            foreach (var CustomerId in CustomerIds)
                            {
                                var studentAttendence = _AttendenceService.GetAttendences().Where(a => a.CustomerId == CustomerId && a.AttendenceDate == StudentAttendence.StartDate).FirstOrDefault();
                                if (studentAttendence != null)
                                {
                                    Mapper.CreateMap <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>();
                                    Onlo.Models.AttendenceModel Attendence = Mapper.Map <Onlo.Entity.Attendence, Onlo.Models.AttendenceModel>(studentAttendence);
                                    var studentDetail = _CustomerService.GetCustomer(studentAttendence.CustomerId);
                                    Attendence.StudentName = studentDetail.Name;
                                    Attendence.StudentCode = studentDetail.StudentCode;
                                    Attendence.ProfilePath = studentDetail.PhotoPath;
                                    Attendence.EmailId     = studentDetail.EmailId;
                                    attendenceList.Add(Attendence);
                                }
                            }
                        }
                    }
                    return(CommonCls.CreateMessage("success", attendenceList));
                }
                else
                {
                    return(CommonCls.CreateMessage("error", "This Customer doesnot exist in this customer type."));
                }
            }
            else
            {
                return(CommonCls.CreateMessage("success", "No attendence found."));
            }
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            StudentAttendence studentAttendence = db.StudentAttendences.Find(id);

            db.StudentAttendences.Remove(studentAttendence);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,ClassOrYearId,TotalStudent,FemaleStudentNo,TotalPresentStudent,PresentFemaleStudent,DateTime")] StudentAttendence studentAttendence)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentAttendence).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClassOrYearId = new SelectList(db.ClassOrYears, "Code", "Name", studentAttendence.ClassOrYearId);
     return(View(studentAttendence));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Attendence_ID,StudentID,Student_datetime,ClassID")] StudentAttendence studentAttendence)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentAttendence).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClassID   = new SelectList(db.ClassTimings, "ClassID", "Class_Name", studentAttendence.ClassID);
     ViewBag.StudentID = new SelectList(db.Students, "StudentID", "StudentName", studentAttendence.StudentID);
     return(View(studentAttendence));
 }
Exemplo n.º 5
0
        // GET: StudentAttendences/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentAttendence studentAttendence = db.StudentAttendences.Find(id);

            if (studentAttendence == null)
            {
                return(HttpNotFound());
            }
            return(View(studentAttendence));
        }
Exemplo n.º 6
0
        // GET: StudentAttendence/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentAttendence studentAttendence = db.StudentAttendences.Find(id);

            if (studentAttendence == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClassOrYearId = new SelectList(db.ClassOrYears, "Code", "Name", studentAttendence.ClassOrYearId);
            return(View(studentAttendence));
        }
Exemplo n.º 7
0
        // GET: StudentAttendences/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentAttendence studentAttendence = db.StudentAttendences.Find(id);

            if (studentAttendence == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ClassID   = new SelectList(db.ClassTimings, "ClassID", "Class_Name", studentAttendence.ClassID);
            ViewBag.StudentID = new SelectList(db.Students, "StudentID", "StudentName", studentAttendence.StudentID);
            return(View(studentAttendence));
        }
Exemplo n.º 8
0
        public HttpResponseMessage GetAttendenceByStudent([FromBody] StudentAttendence StudentAttendence)
        {
            JsonReturnModel result = new JsonReturnModel();

            try
            {
                result = getAttendence(StudentAttendence);
                return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
            }
            catch (Exception ex)
            {
                string ErrorMsg = ex.Message.ToString();
                ErrorLogging.LogError(ex);
                return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
            }
        }
        public ActionResult MarkAttendance(int id, MarkAttendenceViewModel model)
        {
            var todayDate = DateTime.Now.Date;

            if (db.ClassAttendences.Any(c => c.AttendanceDate == todayDate && c.CourseAttendences.Any(d => d.CourseId == id)))
            {
                return(RedirectToAction("CoursesList"));
            }
            var ClassAttendence = new ClassAttendence
            {
                AttendanceDate = DateTime.Now.Date
            };
            var CourseAttendence = new CourseAttendence
            {
                AttendenceId = ClassAttendence.ClassAttendenceId,
                CourseId     = id
            };

            db.CourseAttendences.Add(CourseAttendence);
            db.ClassAttendences.Add(ClassAttendence);
            for (int i = 0; i < model.Students.Count; i++)
            {
                Student Std               = model.Students[i];
                Lookup  lup               = model.Lookups[i];
                var     student           = db.Students.Where(c => c.StudentId == Std.StudentId).SingleOrDefault();
                var     status            = db.Lookups.Where(c => c.LookupId == lup.LookupId).SingleOrDefault();
                var     studentAttendance = new StudentAttendence
                {
                    StudentId        = Std.StudentId,
                    AttendenceStatus = lup.LookupId,
                    AttendenceId     = ClassAttendence.ClassAttendenceId
                };
                db.StudentAttendences.Add(studentAttendance);
            }
            db.SaveChanges();
            return(RedirectToAction("CoursesList"));
        }