コード例 #1
0
        public HttpResponseMessage GetApikey(String Email, String password)
        {
            if (Email == null || password == null)
            {
                var response = Request.CreateResponse(HttpStatusCode.BadRequest);
                return(response);
            }
            else
            {
                bool check = new AccountController().registeredUser(Email, password);
                if (check == true)
                {
                    var  ApiKey = db.Users.FirstOrDefault(u => u.Email == Email).ApiKey;
                    User newobj = db.Users.FirstOrDefault(u => u.Email == Email);

                    if (ApiKey == null)
                    {
                        var newapikey = "";
                        newapikey     = CustomHelpers.GetApiKey();
                        newobj.ApiKey = newapikey;
                        db.SaveChanges();
                    }

                    var response = Request.CreateResponse(HttpStatusCode.OK, ApiKey);
                    return(response);
                }
                else
                {
                    var responses = Request.CreateResponse(HttpStatusCode.Forbidden);
                    return(responses);
                }
            }
        }
コード例 #2
0
        protected override void Seed(GameManager.DAL.GameManagerContext context)
        {
            var users = new List <User> {
                new User {
                    Email = "*****@*****.**", Password = Crypto.HashPassword("password"), ApiKey = CustomHelpers.GetApiKey(), Role = Roles.StoreAdmin
                },
            };

            users.ForEach(u => context.Users.AddOrUpdate(u));
        }