Example #1
0
        public AppConfigs.OperResult AddSchool(SchoolEntity mdl)
        {
            if (User.IsInRole(AppConfigs.AppRole.sys.ToString()) || User.IsInRole(AppConfigs.AppRole.schoolmaster.ToString()))
            {
                var ss = new SchoolSv();
                var se = ss.GetSchool(MyUserId);
                if (se != null) //already has a school
                {
                    se.MakeDay        = DateTime.Now;
                    se.SchoolMasterId = MyUserId;
                    se.SchoolUrl      = mdl.SchoolUrl;
                    se.Memo           = mdl.Memo;
                    return(ss.UpdateSchool(se));
                }
                else
                {
                    mdl.SchoolId       = Guid.NewGuid().ToString("n");
                    mdl.Maker          = MyUserId;
                    mdl.MakeDay        = DateTime.Now;
                    mdl.SchoolMasterId = MyUserId;

                    return(ss.AddSchool(mdl));
                }
            }

            return(AppConfigs.OperResult.failDueToAuthen);
        }
Example #2
0
        public ActionResult add([Bind(Include = "Memo,SchoolmasterPhone,cityId,countryId,provinceId")] SchoolEntity mdl)
        {
            if (ModelState.IsValid)
            {
                mdl.MakeDay  = DateTime.Now;
                mdl.Maker    = MyUserId;
                mdl.SchoolId = Guid.NewGuid().ToString("n");
                mdl.Payed    = false;
                var user = addSchoolMster(mdl.SchoolmasterPhone); //add master user.
                mdl.SchoolMasterId = user.Id;
                var i = schoolSv.AddSchool(mdl);
                return(Json(new { i }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { t = AppConfigs.OperResult.failUnknown }, JsonRequestBehavior.AllowGet));
        }