示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            PetDetails petDetails = db.PetDetails.Find(id);

            db.PetDetails.Remove(petDetails);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Index(string selectedPetType, string selectedPetColor, string petid)
        {
            Console.WriteLine(
                $"AWS_XRAY_DAEMON_ADDRESS:- {Environment.GetEnvironmentVariable("AWS_XRAY_DAEMON_ADDRESS")}");


            AWSXRayRecorder.Instance.BeginSubsegment("Calling Search API");

            AWSXRayRecorder.Instance.AddMetadata("PetType", selectedPetType);
            AWSXRayRecorder.Instance.AddMetadata("PetId", petid);
            AWSXRayRecorder.Instance.AddMetadata("PetColor", selectedPetColor);


            Console.WriteLine(
                $"[{AWSXRayRecorder.Instance.TraceContext.GetEntity().RootSegment.TraceId}]- Search string - PetType:{selectedPetType} PetColor:{selectedPetColor} PetId:{petid}");

            // | SegmentId: [{AWSXRayRecorder.Instance.TraceContext.GetEntity().RootSegment.Id}
            string result;

            try
            {
                result = await GetPetDetails(selectedPetType, selectedPetColor, petid);
            }
            catch (Exception e)
            {
                AWSXRayRecorder.Instance.AddException(e);
                throw e;
            }
            finally
            {
                AWSXRayRecorder.Instance.EndSubsegment();
            }

            var Pets = JsonSerializer.Deserialize <List <Pet> >(result);

            var PetDetails = new PetDetails()
            {
                Pets      = Pets,
                Varieties = new Variety
                {
                    PetTypes         = _variety.PetTypes,
                    PetColors        = _variety.PetColors,
                    SelectedPetColor = selectedPetColor,
                    SelectedPetType  = selectedPetType
                }
            };

            AWSXRayRecorder.Instance.AddMetadata("results", System.Text.Json.JsonSerializer.Serialize(PetDetails));
            Console.WriteLine(
                $" TraceId: [{AWSXRayRecorder.Instance.GetEntity().TraceId}] - {JsonSerializer.Serialize(PetDetails)}");

            // Sets the metric value to the number of pets available for adoption at the moment
            PetsWaitingForAdoption.Set(Pets.Where(pet => pet.availability == "yes").Count());

            return(View(PetDetails));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "PetOwnerID,PetID,OwnerID")] PetDetails petDetails)
 {
     if (ModelState.IsValid)
     {
         db.Entry(petDetails).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OwnerID = new SelectList(db.Owners, "OwnerID", "FirstName", petDetails.OwnerID);
     ViewBag.PetID   = new SelectList(db.Pets, "PetID", "PetName", petDetails.PetID);
     return(View(petDetails));
 }
示例#4
0
 public ActionResult Edit([Bind(Include = "petdetailID,age,ownerfirstName,ownerlastName,petID,vetId")] PetDetails petDetails)
 {
     if (ModelState.IsValid)
     {
         db.Entry(petDetails).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.petID = new SelectList(db.Pets, "petID", "fullName", petDetails.petID);
     ViewBag.vetId = new SelectList(db.Vets, "vetID", "fullName", petDetails.vetId);
     return(View(petDetails));
 }
        public async Task <ActionResult <PetDetails> > FindPet(int petId, CancellationToken cancellationToken)
        {
            var pet = await _petsRepo.FindById(petId, cancellationToken);

            if (pet == null)
            {
                throw new ResourceNotFoundException("Pet " + petId + " not found");
            }

            var ret = new PetDetails(pet);

            return(Ok(ret));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "petOwnerID,ownerID,petID")] PetDetails PetDetails)
        {
            if (ModelState.IsValid)
            {
                db.PetDetails.Add(PetDetails);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ownerID = new SelectList(db.Owners, "ownerID", "fullName", PetDetails.ownerID);
            ViewBag.petID   = new SelectList(db.Pets, "petID", "petName", PetDetails.petID);
            return(View(PetDetails));
        }
示例#7
0
        public void Save(PetDetailsDto pet)
        {
            PetDetails pett = new PetDetails
            {
                Age       = pet.Age,
                ImagePath = pet.ImagePath,
                BreedType = pet.BreedType,
                PetName   = pet.PetName,
                Price     = pet.Price,
                TypeId    = Convert.ToInt32(pet.PetType)
            };

            transRepos.SaveDetails(pett);
        }
示例#8
0
        // GET: PetDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PetDetails petDetails = db.PetDetails.Find(id);

            if (petDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(petDetails));
        }
示例#9
0
 private PetInfoViewModel GetPetInfoViewModel(PetDetails petDetails)
 {
     return(new PetInfoViewModel
     {
         Name = HttpUtility.HtmlDecode(petDetails.Name),
         ProfileImageUrl = petDetails.ProfileImageUrl,
         DateOfBirth = petDetails.DateOfBirth.Date,
         Description = HttpUtility.HtmlDecode(petDetails.Description),
         LostComment = HttpUtility.HtmlDecode(petDetails.LostComment),
         LostDateTime = petDetails.LostDateTime.ToString("dd / MMM / yyyy  hh:mm:ss tt"),
         PositionImageUrl = petDetails.PositionImageUrl,
         Images = petDetails.Images
     });
 }
示例#10
0
        public PetDetailsDto GetPetById(int id)
        {
            PetDetails    petdetails = transRepos.GetPetById(id);
            PetDetailsDto pett       = new PetDetailsDto
            {
                Age       = petdetails.Age,
                ImagePath = petdetails.ImagePath,
                BreedType = petdetails.BreedType,
                PetName   = petdetails.PetName,
                Price     = petdetails.Price,
                PetType   = petdetails.pet.PetType
            };

            return(pett);
        }
示例#11
0
        public void EditPet(PetDetailsDto pd, int petId)
        {
            PetDetails pett = new PetDetails
            {
                Age       = pd.Age,
                PetId     = petId,
                ImagePath = pd.ImagePath,
                BreedType = pd.BreedType,
                PetName   = pd.PetName,
                Price     = pd.Price,
                TypeId    = Convert.ToInt32(pd.PetType)
            };

            transRepos.EditPet(pett);
        }
示例#12
0
        public void Save(PetDetailsDto pet)
        {
            PetDetails pett = new PetDetails
            {
                Age       = pet.Age,
                ImagePath = pet.ImagePath,
                BreedType = pet.BreedType,
                PetName   = pet.PetName,
                Price     = pet.Price,
                TypeId    = Convert.ToInt32(pet.PetType),
                Gender    = pet.Gender
            };

            petRepository.SaveDetails(pett);
        }
示例#13
0
        // GET: PetDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PetDetails petDetails = db.PetDetails.Find(id);

            if (petDetails == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OwnerID = new SelectList(db.Owners, "OwnerID", "FirstName", petDetails.OwnerID);
            ViewBag.PetID   = new SelectList(db.Pets, "PetID", "PetName", petDetails.PetID);
            return(View(petDetails));
        }
示例#14
0
        // GET: PetDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PetDetails petDetails = db.PetDetails.Find(id);

            if (petDetails == null)
            {
                return(HttpNotFound());
            }
            ViewBag.petID = new SelectList(db.Pets, "petID", "fullName", petDetails.petID);
            ViewBag.vetId = new SelectList(db.Vets, "vetID", "fullName", petDetails.vetId);
            return(View(petDetails));
        }
示例#15
0
 /// <summary>
 /// To edit pet record
 /// </summary>
 /// <param name="pd"></param>
 public void EditPet(PetDetails pd)
 {
     db.Entry(pd).State = EntityState.Modified;
     Save();
 }
示例#16
0
 /// <summary>
 /// To save pet record
 /// </summary>
 /// <param name="pdd"></param>
 public void SaveDetails(PetDetails pdd)
 {
     db.petdetails.Add(pdd);
     Save();
 }