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

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

private Post ( [ name, [ description, [ color, FormDataCollection formData ) : IHttpActionResult
name [
description [
color [
formData FormDataCollection
Результат IHttpActionResult
        public IHttpActionResult Post([FromUri] string name, [FromUri] string description, [FromUri] string color, FormDataCollection formData)
        {
            string imagePath = "";
            if (formData["banner"] != null && formData["banner"].Length > 0)
            {
                try
                {
                    var bitmap = ImageDecoder.DecodeBase64String(formData["banner"]);

                    string extension = string.Empty;
                    if (bitmap.RawFormat.Equals(ImageFormat.Jpeg)) extension = ".jpg";
                    if (bitmap.RawFormat.Equals(ImageFormat.Png)) extension = ".png";
                    if (bitmap.RawFormat.Equals(ImageFormat.Bmp)) extension = ".bmp";
                    if (bitmap.RawFormat.Equals(ImageFormat.Gif)) extension = ".gif";

                    if (string.IsNullOrEmpty(extension)) return Content(HttpStatusCode.InternalServerError, "The supplied image is not a valid image");

                    imagePath = FileHelper.NextAvailableFilename(Path.Combine(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["OrganisationsImgPath"]), "organisation" + extension));
                    bitmap.Save(imagePath);

                    imagePath = Path.GetFileName(imagePath);
                }
                catch (Exception ex)
                {
                    Content(HttpStatusCode.InternalServerError, ex);
                }
            }

            var userIdentity = RequestContext.Principal.Identity as ClaimsIdentity;
            if (userIdentity == null) return InternalServerError();

            var email = userIdentity.Claims.First(c => c.Type == "sub").Value;
            if (email == null) return InternalServerError();

            var user = userManager.ReadUser(email);
            if (user == null) return InternalServerError();

            if (organisationManager.ReadOrganisation(name) != null)
            {
                return InternalServerError(new Exception("Organisation name already exists"));
            }

            Organisation organisation = organisationManager.CreateOrganisation(name, imagePath, user);
            return Ok(organisation);
        }