Пример #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 }));
            }
        }
Пример #2
0
        public JsonResult GetDoctors(int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
        {
            List <customUser> customResult = new List <customUser>();

            db.Configuration.ProxyCreationEnabled = false;
            var result = db.Users.Where(x => x.UserGroupID == 4).ToList();

            foreach (var item in result)
            {
                customUser usr = new customUser();
                usr.ID       = item.ID;
                usr.Username = item.Username;
                var subjects = db.User_Subject.Where(x => x.UserID == usr.ID).FirstOrDefault();

                usr.SubjectID = subjects != null ? subjects.SubjectID : 0;
                customResult.Add(usr);
            }
            return(Json(new { Records = customResult.ToList(), Result = "OK", TotalRecordCount = result.Count() }));
        }