Exemple #1
0
        public JsonResult UpdateDoctor(customUser user)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }));
                }
                User_Subject updatedUser = new User_Subject();
                var          userSub     = db.User_Subject.Where(x => x.UserID == user.ID).FirstOrDefault();
                if (userSub != null)
                {
                    userSub.SubjectID = user.SubjectID;

                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    updatedUser.UserID        = user.ID;
                    updatedUser.SubjectID     = user.SubjectID;
                    updatedUser.SubjectStatus = "Open";
                    db.User_Subject.Add(updatedUser);
                    db.SaveChanges();
                }
                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Exemple #2
0
 public JsonResult CreateAnswer(Answer quiz)
 {
     try
     {
         var items = db.Answers.Where(x => x.QuizID == quiz.QuizID && x.AnswerValue == 1).ToList();
         if (items != null)
         {
             if (items.Count > 0)
             {
                 foreach (var item in items)
                 {
                     item.AnswerValue     = 2;
                     db.Entry(item).State = EntityState.Modified;
                     db.SaveChanges();
                 }
             }
         }
         var result = db.Answers.Add(quiz);
         db.SaveChanges();
         return(Json(new { Result = "OK", Record = result }));
     }
     catch (Exception ex)
     {
         return(Json(new { Result = "ERROR", Message = ex.Message }));
     }
 }
Exemple #3
0
        public JsonResult Create(Lecture Lecture)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }));
                }

                else
                {
                    var addedStudent = db.Lectures.Add(Lecture);
                    db.SaveChanges();
                    int sID     = (int)addedStudent.SubjectID;
                    var userIDs = db.User_Subject.Where(x => x.SubjectID == sID).Select(y => y.UserID);
                    var mails   = db.Users.Where(x => userIDs.Contains(x.ID)).Select(y => y.Username).ToList();
                    var phones  = db.Users.Where(x => userIDs.Contains(x.ID)).Select(y => y.Phone).ToList();
                    if (addedStudent.StartsOn.HasValue)
                    {
                        for (int i = 0; i < mails.Count; i++)
                        {
                            var MailHelper = new MailHelper
                            {
                                Sender      = "*****@*****.**",
                                Recipient   = mails[i],
                                RecipientCC = null,
                                Subject     = "FCIH E-Learning New Lecture Added",
                                Body        = "New Lecture Of You Has Been Created " + addedStudent.Title + " Starts On " + addedStudent.StartsOn.Value.ToString()
                            };
                            MailHelper.Send();
                        }
                        for (int i = 0; i < phones.Count; i++)
                        {
                            new BaseClass().SendSMS(phones[i].Value.ToString(), "New Lecture Of You Has Been Created " + addedStudent.Title + " Starts On " + addedStudent.StartsOn.Value.ToString());
                        }
                    }

                    return(Json(new { Result = "OK", Record = addedStudent }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Exemple #4
0
        public void SendMessage(string msg, string subjectID)
        {
            var     usr    = (E_LearningFCIH.DAL.User)Session["_CurrentFCIHUser"];
            Message newmsg = new Message();

            newmsg.CreatedOn   = DateTime.Now;
            newmsg.MessageBody = msg;
            newmsg.SubjectID   = int.Parse(subjectID);
            newmsg.UserID      = usr.ID;
            db.Messages.Add(newmsg);
            db.SaveChanges();
        }
Exemple #5
0
        public ActionResult SaveImages(string Title, HttpPostedFileBase file)

        {
            DAL.Entities         DC              = new DAL.Entities();
            System.Drawing.Image sourceimage     = System.Drawing.Image.FromStream(file.InputStream);
            ImageConverter       _imageConverter = new ImageConverter();

            byte[]    xByte = (byte[])_imageConverter.ConvertTo(sourceimage, typeof(byte[]));
            DAL.Image _img  = new DAL.Image();
            _img.Title = Title;
            _img.File  = xByte;
            DC.Image.Add(_img);
            DC.SaveChanges();
            return(RedirectToAction("Index", "Images"));
        }
        public void RegisterCourseProcess()
        {
            var           user     = (User)Session["_CurrentFCIHUser"];
            List <string> subjects = new List <string>();

            if (Convert.ToInt32(Request["firstSubject"]) != -1 && !string.IsNullOrEmpty(Request["firstSubject"]))
            {
                subjects.Add(Request["firstSubject"]);
            }
            if (Convert.ToInt32(Request["secondSubject"]) != -1 && !string.IsNullOrEmpty(Request["secondSubject"]))
            {
                subjects.Add(Request["secondSubject"]);
            }
            if (Convert.ToInt32(Request["thirdSubject"]) != -1 && !string.IsNullOrEmpty(Request["thirdSubject"]))
            {
                subjects.Add(Request["thirdSubject"]);
            }
            if (Convert.ToInt32(Request["fourthSubject"]) != -1 && !string.IsNullOrEmpty(Request["fourthSubject"]))
            {
                subjects.Add(Request["fourthSubject"]);
            }

            subjects = subjects.Distinct().ToList();

            if (subjects.Count > 0)
            {
                for (int i = 0; i < subjects.Count; i++)
                {
                    DAL.User_Subject userSubject = new DAL.User_Subject();
                    userSubject.UserID        = user.ID;
                    userSubject.SubjectID     = Convert.ToInt32(subjects[i]);
                    userSubject.SubjectStatus = Status.Request.ToString();
                    entity.User_Subject.Add(userSubject);
                }
                entity.SaveChanges();
            }
        }