Esempio n. 1
0
        public IdentityResult Register(AccountModel model)
        {
            var userStore   = new UserStore <ApplicationUser>(new ApplicationDbContext());
            var userManager = new UserManager <ApplicationUser>(userStore);

            var user = new ApplicationUser {
                UserName = model.Email, Email = model.Email
            };

            user.FirstName      = model.FirstName;
            user.LastName       = model.LastName;
            user.PhoneNumber    = model.PhoneNumber;
            user.RegisteredDate = DateTime.Now;


            IdentityResult result = userManager.Create(user, model.Password);

            if (result.Succeeded)
            {
                userManager.AddToRole(user.Id, "Victim");
            }
            var data = new VictimModel();
            var v    = _victim.InsertVictim(data, user.Id);

            return(result);
        }
        public HttpResponseMessage AddVictimProfile(VictimModel entity)
        {
            var user   = HttpContext.Current.User.Identity as ClaimsIdentity;
            var userId = user.FindFirst("UserId").Value;
            var city   = _victim.InsertVictim(entity, userId);

            if (city > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, city));
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound, city));
        }