Beispiel #1
0
        public ActionResult Create([Bind(Include = "VersionId,BuidDate,Version,UpdateMessage,Notes")] tblAppVersion tblAppVersion)
        {
            if (ModelState.IsValid)
            {
                db.tblAppVersions.Add(tblAppVersion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblAppVersion));
        }
Beispiel #2
0
        public JsonResult UpdateToken(long UserId, string SenderId)
        {
            var User = db.tblAppLogins.Where(x => x.Id == UserId).Select(y => y).SingleOrDefault();

            User.SenderId        = SenderId;
            db.Entry(User).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(new { status = true }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult SaveAttendance(long OrgId, string StudentId, string scanDateTime, bool IsPicUp)
        {
            string Status  = string.Empty;
            string message = string.Empty;

            try
            {
                var      datee   = ConvertToDateTime(scanDateTime);
                string[] arrlong = StudentId.Split(',');
                foreach (var temp in arrlong)
                {
                    DbContext.tblAttendanceHourlies.Add(new tblAttendanceHourly()
                    {
                        StudentId = Convert.ToInt64(temp),
                        IsPickUp  = IsPicUp,
                        Time      = new TimeSpan(datee.Hour, datee.Minute, datee.Second),
                        Date      = new DateTime(datee.Year, datee.Month, datee.Day),
                        OrgId     = OrgId
                    });
                    DbContext.SaveChanges();
                    var    Student  = DbContext.tblStudents.Where(x => x.Id.ToString() == StudentId).Select(y => y).FirstOrDefault();
                    string Number   = "+91" + Student.ContactNo;
                    string Username = "******";
                    string Password = "******";
                    string Source   = "SSGBLR";
                    if (IsPicUp == true)
                    {
                        Status = "Pickedup";
                    }
                    if (IsPicUp == false)
                    {
                        Status = "Dropped";
                    }

                    string Content = "Its Here By To Notify Your Kid Master. " + Student.FirstName + " " + Student.MiddleName + " " + Student.LastName + " " + "Has " + Status;

                    string          strUrl         = "http://103.16.101.52:8080/sendsms/bulksms?username="******"&password="******"&type=0&dlr=1&destination=" + Number + "&source=" + Source + "&message=" + Content;
                    HttpWebRequest  _createRequest = (HttpWebRequest)WebRequest.Create(strUrl);
                    HttpWebResponse response       = (HttpWebResponse)_createRequest.GetResponse();
                    Stream          s          = (Stream)response.GetResponseStream();
                    StreamReader    readStream = new StreamReader(s);
                    string          dataString = readStream.ReadToEnd();
                    response.Close();
                    s.Close();
                    readStream.Close();
                }
                return(Json(new { status = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new { status = false, message = e.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult VerifyLogin(string Username, string Password)
        {
            webSchoolContext db = new webSchoolContext();

            db.tblAppLogins.Add(new tblAppLogin()
            {
                Email    = Username,
                Password = Password
            });
            db.SaveChanges();
            return(Json("Saved Successfully", JsonRequestBehavior.AllowGet));
        }
 public JsonResult UpdateRouteLocation(long Routecode, long OrgId, string Lattitude, string Longitude)
 {
     try
     {
         var datee = DateTime.Now;
         db.tblGPSDatas.Add(new tblGPSData()
         {
             RouteCode = Routecode,
             OrgId     = OrgId,
             Latitude  = float.Parse(Lattitude),
             Longitude = float.Parse(Longitude),
             Time      = new DateTime(datee.Year, datee.Month, datee.Day, datee.Hour, datee.Minute, datee.Second)
         });
         db.SaveChanges();
         return(Json("Saved Successfully", JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(e.ToString(), JsonRequestBehavior.AllowGet));
     }
 }
        public JsonResult SaveAttendance(long OrgId, string StudentId, string scanDateTime, bool IsCheckIn)
        {
            try
            {
                DuplicateAttendance DuplicateAttendanceObj = new DuplicateAttendance();
                var      datee   = ConvertToDateTime(scanDateTime);
                var      NowDate = new DateTime(datee.Year, datee.Month, datee.Day);
                string[] arrlong = null;
                if (StudentId.Contains(','))
                {
                    arrlong = StudentId.Split(',');
                }
                else
                {
                    arrlong = new string[] { StudentId };
                }
                DuplicateAttendanceObj.DuplicatesList = new List <Dupicates>();

                if (IsCheckIn == true)
                {
                    foreach (var temp in arrlong)
                    {
                        long StudId           = Convert.ToInt64(temp);
                        var  DuplicateCheckIn = DbContext.tblAttendanceHourlies.Where(x => x.OrgId == OrgId && x.StudentId == StudId && x.Date == NowDate && x.IsAttendance == true).OrderByDescending(x => x.Time).Take(1).Select(y => y).FirstOrDefault();
                        if (DuplicateCheckIn == null || DuplicateCheckIn.IsPickUp == false)
                        {
                            DbContext.tblAttendanceHourlies.Add(new tblAttendanceHourly()
                            {
                                StudentId    = Convert.ToInt64(temp),
                                IsPickUp     = IsCheckIn,
                                IsAttendance = true,
                                Time         = new TimeSpan(datee.Hour, datee.Minute, datee.Second),
                                Date         = new DateTime(datee.Year, datee.Month, datee.Day),
                                OrgId        = OrgId
                            });
                            DbContext.SaveChanges();
                        }
                        else
                        {
                            var StudnetDuplicate = new Dupicates();
                            DuplicateAttendanceObj.DuplicatesList.Add(StudnetDuplicate);
                            StudnetDuplicate.StudentId             = Convert.ToInt64(temp);
                            DuplicateAttendanceObj.ReasonDuplicate = "Already Checked In";
                        }
                    }
                    return(Json(new { status = true, DuplicateAttendanceObj }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    foreach (var temp in arrlong)
                    {
                        long StudId = Convert.ToInt64(temp);
                        var  Dup    = DbContext.tblAttendanceHourlies.Where(x => x.OrgId == OrgId && x.StudentId == StudId && x.Date == NowDate && x.IsAttendance == true && x.IsPickUp == true).OrderByDescending(x => x.Time).Take(1).Select(y => y).FirstOrDefault();
                        if (Dup != null)
                        {
                            var      d = new TimeSpan(Dup.Time.Hours, Dup.Time.Minutes, Dup.Time.Seconds);
                            var      e = new TimeSpan(datee.Hour, datee.Minute, datee.Second);
                            TimeSpan f = e.Subtract(d);
                            if (f.Hours >= 2)
                            {
                                DbContext.tblAttendanceHourlies.Add(new tblAttendanceHourly()
                                {
                                    StudentId    = Convert.ToInt64(temp),
                                    IsPickUp     = IsCheckIn,
                                    IsAttendance = true,
                                    Time         = new TimeSpan(datee.Hour, datee.Minute, datee.Second),
                                    Date         = new DateTime(datee.Year, datee.Month, datee.Day),
                                    OrgId        = OrgId
                                });
                                DbContext.SaveChanges();
                            }
                            else
                            {
                                var StudnetDuplicate = new Dupicates();
                                DuplicateAttendanceObj.DuplicatesList.Add(StudnetDuplicate);
                                StudnetDuplicate.StudentId             = Convert.ToInt64(temp);
                                DuplicateAttendanceObj.ReasonDuplicate = "Below 2 Hrs Checkin";
                            }
                        }
                        else
                        {
                            var StudnetDuplicate = new Dupicates();
                            DuplicateAttendanceObj.DuplicatesList.Add(StudnetDuplicate);
                            StudnetDuplicate.StudentId             = Convert.ToInt64(temp);
                            DuplicateAttendanceObj.ReasonDuplicate = "Not Checkin can't CheckOut";
                        }
                    }
                    return(Json(new { status = true, DuplicateAttendanceObj }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json(new { status = false, message = e.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }
 public JsonResult SendEmailVerificationCode(string Email)
 {
     try
     {
         string message    = string.Empty;
         var    HasStudent = db.tblStudents.Where(x => x.FatherEmail == Email || x.MotherEmail == Email).Select(u => u.StudentId).ToList();
         if (HasStudent.Count != 0)
         {
             var HasDuplicate = db.tblAppLogins.Where(x => x.Email == Email && x.IsRegistered == true).Select(x => new { x.Email }).SingleOrDefault();
             if (HasDuplicate == null)
             {
                 var Duplicate = db.tblAppLogins.Where(x => x.Email == Email).SingleOrDefault();
                 if (Duplicate == null)
                 {
                     tblAppLoginobj.Email = Email;
                     string        Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                     Random        rand     = new Random();
                     int           size     = 6;
                     StringBuilder Passcode = new StringBuilder();
                     char[]        chars    = new char[size];
                     for (int i = 0; i < size; i++)
                     {
                         chars[i] = Alphabet[rand.Next(Alphabet.Length)];
                         Passcode.Append(chars[i]);
                     }
                     tblAppLoginobj.IsRegistered = false;
                     tblAppLoginobj.Passcode     = Passcode.ToString();
                     db.tblAppLogins.Add(tblAppLoginobj);
                     db.SaveChanges();
                     string Body    = "<html><body> Hi there! <br /><br /> Your Verification Code is:" + Passcode + "</body></html>";
                     string subject = "Verification Code";
                     EmailHelper.TrySendEmail(subject, Body, Email);
                     return(Json(new { status = true }, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     string        Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                     Random        rand     = new Random();
                     int           size     = 6;
                     StringBuilder Passcode = new StringBuilder();
                     char[]        chars    = new char[size];
                     for (int i = 0; i < size; i++)
                     {
                         chars[i] = Alphabet[rand.Next(Alphabet.Length)];
                         Passcode.Append(chars[i]);
                     }
                     tblAppLoginobj.IsRegistered = false;
                     Duplicate.Passcode          = Passcode.ToString();
                     tblAppLoginobj.Passcode     = Passcode.ToString();
                     db.Entry(Duplicate).State   = EntityState.Modified;
                     db.SaveChanges();
                     string Body    = "<html><body> Hi there! <br /><br /> Your Verification Code is:" + Passcode + "</body></html>";
                     string subject = "Verification Code";
                     EmailHelper.TrySendEmail(subject, Body, Email);
                     return(Json(new { status = true }, JsonRequestBehavior.AllowGet));
                 }
             }
             else
             {
                 message = string.Format("Already Registered!");
                 return(Json(new { status = false, Message = message }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             message = string.Format("Email Not Saved As Parents Email");
             return(Json(new { status = false, Message = message }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception e)
     {
         return(Json(new { status = false, Message = e.ToString() }, JsonRequestBehavior.AllowGet));
     }
 }