Пример #1
0
        // POST: api/Api
        //create a username and password that the student can use to sign in. Return an id for the api
        public JsonResult PostRegister(string username, string password, string email, string major)
        {
            bool   success = false;
            string message = "Registered user";
            string userId  = "null";
            ApplicationUserManager usermanager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>();

            var user = new ApplicationUser {
                UserName = username, Email = email
            };
            var result = usermanager.Create(user, password);

            usermanager.AddToRole(user.Id, "student");

            success = result.Succeeded;
            if (!success)
            {
                message = "password must contain 1 upercase 1 lowercase and one symbol, must be >= 6 chars";
                userId  = new entityId().generateId();
                return(new JsonResult
                {
                    Data = new { success = success,
                                 message = message,
                                 id = userId },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            db.SaveChanges();
            //create a new user in major entry for them to use later
            var UIM = new UserInMajor {
                Id = user.Id, Major = major
            };

            db.UserInMajors.Add(UIM);
            db.SaveChanges();

            return(new JsonResult
            {
                Data = new { success = success,
                             message = message,
                             id = user.Id },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #2
0
 _componentManager.Add(entityId, value);
Пример #3
0
 public void Add <T>(uint entityId, in T value) where T : struct => ((ComponentPool <T>)_componentMaps[ComponentId <T> .Id]).Add(entityId, value);