Beispiel #1
0
        public async Task <IActionResult> SaveProfile(UserProfileViewModel model)
        {
            UserProfileModel m = model.GetProfileModel();

            const double maxSize = 368640; // 350x350 24 bit bmp file size

            if (model.Files != null && model.Files.Length > 0)
            {
                byte[] imageBytes = null;

                using (MemoryStream stream = new MemoryStream())
                {
                    model.Files.CopyTo(stream);
                    imageBytes = stream.ToArray();
                }

                if (ImageHelper.isKnownFormat(imageBytes) &&
                    (ImageHelper.IsImageFit(imageBytes, 350)))
                {
                    m.Image = imageBytes;
                }
            }

            SQLData.UpdateProfile(m);

            return(RedirectToAction("Profile"));
        }