Esempio n. 1
0
 public static string register(string openId, string nickName, string avatarUrl, string sex)
 {
     try
     {
         using (var db = new AIUniversityEntities())
         {
             var user = db.User.FirstOrDefault(s => s.OpenID == openId);
             if (user == null)
             {
                 user            = new User();
                 user.ID         = Guid.NewGuid().ToString().Replace("-", "").ToLower();
                 user.Name       = nickName;
                 user.Picture    = avatarUrl;
                 user.OpenID     = openId;
                 user.CreateTime = DateTime.Now;
                 user.Sex        = sex;
                 db.User.Add(user);
                 db.SaveChanges();
             }
             var ret = new
             {
                 data   = user,
                 result = 1
             };
             return(Obj2Json(ret));
         }
     }
     catch (Exception e)
     {
         LogHelper.WriteException(e);
         return(Obj2Json(new
         {
             result = -1,
             errmsg = e.Message
         }));
     }
 }
Esempio n. 2
0
 public static string updateUser(string userId, string nickName, string mobile, string xueli, string zhuanye, string age)
 {
     using (var db = new AIUniversityEntities())
     {
         var user = db.User.SingleOrDefault(s => s.ID == userId);
         if (user != null)
         {
             if (nickName != null && nickName != "")
             {
                 user.Name = nickName;
             }
             if (mobile != null && mobile != "")
             {
                 user.Phone = mobile;
             }
             if (xueli != null && xueli != "")
             {
                 user.Xueli = xueli;
             }
             if (zhuanye != null && zhuanye != "")
             {
                 user.Zhuanye = zhuanye;
             }
             if (age != null && age != "")
             {
                 user.Age = age;
             }
         }
         var ret = new
         {
             user,
             result = db.SaveChanges()
         };
         return(Obj2Json(ret));
     }
 }
Esempio n. 3
0
        public static string insertBachelorData(
            string userId,
            string targetCountry,
            float GPA,
            string GPAType,
            int language,
            string languageType,
            int standardization,
            string standardizationType,
            string toSchool,
            string inclination,
            string graduation,
            string rank,
            string recommend,
            string prize,
            string summer,
            string volunteer)
        {
            float GPA_Four    = 0.0f;
            float GPA_Hundred = 0.0f;
            int   TOEFL       = 0;
            int   IELTS       = 0;
            int   GRE_Score   = 0;
            int   CMAT_Score  = 0;

            if (GPAType == "四分制")
            {
                GPA_Four    = GPA;
                GPA_Hundred = 0.0f;
            }
            else
            {
                GPA_Four    = 0.0f;
                GPA_Hundred = GPA;
            }
            if (languageType == "托福")
            {
                TOEFL = language;
                IELTS = 0;
            }
            else
            {
                TOEFL = 0;
                IELTS = language;
            }
            if (standardizationType == "SAT")
            {
                GRE_Score  = standardization;
                CMAT_Score = 0;
            }
            else if (standardizationType == "ACT")
            {
                GRE_Score  = 0;
                CMAT_Score = standardization;
            }
            else
            {
                GRE_Score  = 0;
                CMAT_Score = 0;
            }
            string   id     = Guid.NewGuid().ToString().Replace("-", "").ToLower();
            DateTime dt_now = DateTime.Now;

            using (var db = new AIUniversityEntities())
            {
                db.User_Bachelor_Log.Add(
                    new User_Bachelor_Log
                {
                    ID                      = id,
                    User_ID                 = userId,
                    Target_Country          = targetCountry,
                    GPA_Four                = GPA_Four,
                    GPA_Hundred             = GPA_Hundred,
                    TOEFL                   = TOEFL,
                    IELTS                   = IELTS,
                    SAT                     = GRE_Score,
                    ACT                     = CMAT_Score,
                    Target_JoinTime         = toSchool,
                    Prefed_SchoolType       = inclination,
                    MiddleSchool_Type       = graduation,
                    MiddleSchool_GradeLevel = rank,
                    Recommendation          = recommend,
                    Award                   = prize,
                    Summer_Program          = summer,
                    Volunteer_Experience    = volunteer,
                    Insert_Date             = dt_now
                });
                var query = from univer in db.University
                            where univer.CountryName == targetCountry
                            join enroll in db.University_Enroll_Status
                            on univer.University_ID.ToString() equals enroll.University_ID
                            into temp
                            from tt in temp.DefaultIfEmpty()
                            orderby tt.录取难度
                            orderby tt.录取率
                            select new
                {
                    univer.University_ID
                };
                var resultList = query.ToList();
                int type       = 0;
                for (int i = 0; i < resultList.Count; i++)
                {
                    if (i < 2)
                    {
                        type = 1;
                    }
                    else if (i <= 3)
                    {
                        type = 2;
                    }
                    else
                    {
                        type = 3;
                    }
                    db.User_Result_Log.Add(
                        new User_Result_Log
                    {
                        User_ID             = userId,
                        UserLog_ID          = id,
                        University_ResultId = resultList[i].University_ID.ToString(),
                        Insert_Date         = dt_now,
                        type = type,
                        sort = i + 1
                    });
                }
                db.SaveChanges();
                return(Obj2Json(new
                {
                    data = id,
                    result = 1
                }));
            }
        }
Esempio n. 4
0
        public static string insertMasterData(
            string userId,
            string targetCountry,
            string school,
            string major1,
            string major2,
            float GPA,
            string GPAType,
            int language,
            string languageType,
            int standardization,
            string standardizationType,
            string toSchool,
            string experience,
            string paper,
            string recommendation,
            string overseas,
            string practice)
        {
            DateTime createTime  = DateTime.Now;
            float    GPA_Four    = 0.0f;
            float    GPA_Hundred = 0.0f;
            int      TOEFL       = 0;
            int      IELTS       = 0;
            int      GRE_Score   = 0;
            int      CMAT_Score  = 0;
            string   id          = Guid.NewGuid().ToString().Replace("-", "").ToLower();

            if (GPAType == "四分制")
            {
                GPA_Four    = GPA;
                GPA_Hundred = 0.0f;
            }
            else
            {
                GPA_Four    = 0.0f;
                GPA_Hundred = GPA;
            }
            if (languageType == "托福")
            {
                TOEFL = language;
                IELTS = 0;
            }
            else
            {
                TOEFL = 0;
                IELTS = language;
            }
            if (standardizationType == "GRE")
            {
                GRE_Score  = standardization;
                CMAT_Score = 0;
            }
            else if (standardizationType == "GMAT")
            {
                GRE_Score  = 0;
                CMAT_Score = standardization;
            }
            else
            {
                GRE_Score  = 0;
                CMAT_Score = 0;
            }
            using (var db = new AIUniversityEntities())
            {
                db.User_Master_Log.Add(new User_Master_Log
                {
                    ID                  = id,
                    User_ID             = userId,
                    Target_Country      = targetCountry,
                    Current_University  = school,
                    Current_Major       = major1,
                    Target_Major        = major2,
                    GPA_Four            = GPA_Four,
                    GPA_Hundred         = GPA_Hundred,
                    TOEFL               = TOEFL,
                    IELTS               = IELTS,
                    GRE_Score           = GRE_Score,
                    CMAT_Score          = CMAT_Score,
                    Target_JoinTime     = toSchool,
                    Research_Experience = experience,
                    Paper_Publish       = paper,
                    Recommendation      = recommendation,
                    Abroad_Experience   = overseas,
                    Working_Experience  = practice,
                    Insert_Date         = createTime
                });
                var query = from univer in db.University
                            where univer.CountryName == targetCountry
                            join enroll in db.University_Enroll_Status
                            on univer.University_ID.ToString() equals enroll.University_ID
                            into temp
                            from tt in temp.DefaultIfEmpty()
                            orderby tt.录取难度 descending
                            select new
                {
                    univer.University_ID
                };
                var resultList = query.ToList();
                int type       = 0;
                for (int i = 0; i < resultList.Count; i++)
                {
                    if (i < 2)
                    {
                        type = 1;
                    }
                    else if (i <= 3)
                    {
                        type = 2;
                    }
                    else
                    {
                        type = 3;
                    }
                    db.User_Result_Log.Add(
                        new User_Result_Log
                    {
                        User_ID             = userId,
                        UserLog_ID          = id,
                        University_ResultId = resultList[i].University_ID.ToString(),
                        Insert_Date         = createTime,
                        type = type,
                        sort = i + 1
                    });
                }
                db.SaveChanges();
            }
            throw new NotImplementedException();
        }