public async Task <IActionResult> CreatePetAccount(PetWithImage model)
        {
            try
            {
                model.PetAccount.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier);

                await _uploadImageService.CreatePetAccountUploadImage(model);


                _repo.PetAccount.Create(model.PetAccount);
                _repo.Save();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ViewBag.error = "Failed to create Account";
                return(RedirectToAction("Index", "Home"));
            }
            await _userManager.AddClaimAsync(await _userManager.FindByNameAsync(User.Identity.Name), new Claim(ClaimTypes.Role, "Pet Owner"));

            await _signInManager.RefreshSignInAsync(await _userManager.FindByNameAsync(User.Identity.Name));

            _context.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
        // GET: MedicalRecords/Create
        public IActionResult Create(int petId)
        {
            MedicalRecord medicalRecord = new MedicalRecord();

            medicalRecord.PetId = petId;
            _context.MedicalRecords.Add(medicalRecord);
            _context.SaveChanges();
            return(RedirectToAction("Index", "MedicalRecords", new { petId = medicalRecord.PetId }));
        }
        public ActionResult AddImage(PhotoBin image, IFormFile upload)
        {
            using (var memoryStream = new MemoryStream())
            {
                upload.CopyToAsync(memoryStream);
                image.Content = memoryStream.ToArray();

                string Base64 = Convert.ToBase64String(image.Content);
                byte[] array  = Convert.FromBase64String(Base64);
                _context.PhotoBins.Add(image);
                _context.SaveChanges();
                return(View());
            }
        }
 public void Save()
 {
     _context.SaveChanges();
 }