示例#1
0
        public async Task <ActionResult <Relation> > RegisterShelter(string userId, string shelterName, string shelterEmail, string shelterImage, int capacity, float lat, float lng)
        {
            var shelter = new Shelter();

            shelter.Name      = shelterName;
            shelter.Image     = shelterImage;
            shelter.Email     = shelterEmail;
            shelter.Capacity  = capacity;
            shelter.Latitude  = lat;
            shelter.Longitude = lng;
            _context.Shelter.Add(shelter);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ShelterExists(shelter.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(Redirect("/add-relation/" + shelter.Id + "/" + userId));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, PetBio petBio)
        {
            if (id != petBio.PetBioId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(petBio);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PetBioExists(petBio.PetBioId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["PetId"] = new SelectList(_context.PetAccounts, "PetAccountId", "PetAccountId", petBio.PetId);
            return(View(petBio));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, BlockedUsers blockedUsers)
        {
            if (id != blockedUsers.BlockedUserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blockedUsers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlockedUsersExists(blockedUsers.BlockedUserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PetAccountId"] = new SelectList(_context.PetAccounts, "PetAccountId", "PetAccountId", blockedUsers.BlockedUserId);
            return(View(blockedUsers));
        }
        public async Task <IActionResult> CreateImmunizationDb(Immunization immunization)
        {
            _context.Immunizations.Add(immunization);
            await _context.SaveChangesAsync();

            var           medicalId     = immunization.MedicalRecordId;
            MedicalRecord medicalRecord = _context.MedicalRecords.Where(r => r.MedicalRecordId == medicalId).FirstOrDefault();

            return(RedirectToAction("Index", "MedicalRecords", new { petId = medicalRecord.PetId }));
        }
        public async Task <ActionResult <AdoptionRequest> > AddAdoptionRequest([FromBody] AdoptionRequest adoptionRequest)
        {
            _context.adoptionRequests.Add(adoptionRequest);
            try
            {
                //EmailHelper.EmailHelper helper = new EmailHelper.EmailHelper();

                //helper.sendEmail(new MailAddress("*****@*****.**"), "*****@*****.**", "Pet Adoption", adoptionRequest.AdoptionMessasge);

                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (AdoptionRequestExists(adoptionRequest.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
        public async Task <ActionResult <Shelter> > AddRelation(int userId, int shelterId)
        {
            var relation = new UserShelterRelation();

            relation.ShelterId = shelterId;
            relation.UserId    = userId;

            _context.UserShelterRelations.Add(relation);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (UserShelterRelationExists(relation.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction("Login", "User"));
        }
        public async Task <ActionResult <Animal> > PostAnimal([FromBody] Animal animal)
        {
            _context.Animal.Add(animal);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (AnimalExists(animal.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }