BB.UI.Web.MVC.Controllers.Web_API.UserController.Register C# (CSharp) Метод

Register() приватный Метод

private Register ( [ firstName, [ lastName, [ nickname, [ email, [ password, [ imageUrl ) : Task
firstName [
lastName [
nickname [
email [
password [
imageUrl [
Результат Task
        public async Task<IHttpActionResult> Register([FromUri] string firstName, [FromUri] string lastName, [FromUri] string nickname, [FromUri] string email, [FromUri] string password, [FromUri] string imageUrl)
        {
            User user;

            if (imageUrl != null)
            {
                // TODO check for file extension / MIME types?

                if(!(imageUrl.ToLower().EndsWith(".png") || imageUrl.ToLower().EndsWith(".jpg") || imageUrl.ToLower().EndsWith(".jpeg") || imageUrl.ToLower().EndsWith(".gif")))
                {
                    return Content(HttpStatusCode.BadRequest, "The supplied image URL is not an image");
                }

                var imageFileName = Path.GetFileName(imageUrl);
                var imagePath = FileHelper.NextAvailableFilename(Path.Combine(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["UsersImgPath"]), imageFileName));

                var webClient = new WebClient();
                webClient.DownloadFile(imageUrl, imagePath);
                imageUrl = Path.GetFileName(imagePath);
            }

            try
            {
                user = userManager.CreateUser(email, lastName, firstName, nickname, imageUrl ?? "");
            }
            catch (Exception ex)
            {
                return Content(HttpStatusCode.InternalServerError, ex.GetBaseException().Message);
            }

            var applicationUser = new ApplicationUser { UserName = email, Email = email };
            var resultUser = await UserManager.CreateAsync(applicationUser, password);

            if (resultUser.Succeeded){
                UserManager.AddToRole(applicationUser.Id, "User");
                return Ok(user);
            }
                userManager.DeleteUser(user.Id);
                return Content(HttpStatusCode.InternalServerError, "ASP.NET Identity Usermanager could not create user");
            }