public async Task<IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            return Ok();
        }
Esempio n. 2
0
        public async Task<IHttpActionResult> Register2Mobile(RegisterBindingModel foo)
        {

            var contentType = Request.Content.Headers.ContentType.MediaType;
         //   var pp = System.Web.HttpContext.Current.Request["RegisterBindingModel"];

         //   RegisterBindingModel foo = Newtonsoft.Json.JsonConvert.DeserializeObject<RegisterBindingModel>(pp) as RegisterBindingModel;



            var httpRequest = HttpContext.Current.Request;



            if (httpRequest.Files.Count > 0)
            {
                foreach (string file in httpRequest.Files)
                {
                    var files = new List<string>();
                    if (file == "FileUpload")
                    {

                        var postedFile = httpRequest.Files[file];
                        var vfile = postedFile.FileName.Replace("\"", string.Empty).Replace("'", string.Empty);

                        vfile = Stp(vfile);
                        string FileName = HttpContext.Current.Server.MapPath("~/Img/" + vfile);
                        //   dd.cac_file = "/images/" + vfile;

                        foo.LogoPath = "Img/" + vfile;

                        postedFile.SaveAs(FileName);



                    }
                }

            }



            var user = new ApplicationUser() { UserName = foo.Email, Email = foo.Email, LogoPath = foo.LogoPath, Security_Question = foo.Security_Question, First_Name = foo.First_Name, Surname_Name = foo.Surname_Name, PhoneNumber = foo.PhoneNumber, Security_Answer = foo.Security_Answer };


            IdentityResult result = await UserManager.CreateAsync(user, foo.Password);

            if (!result.Succeeded)
            {

                return GetErrorResult(result);
            }
            //  return   Request.CreateErrorResponse(HttpStatusCode.Created,
            sendemail(foo.Email, foo.Email);
            return Ok();
        }