public IActionResult Index(int id) { AnimalDetails model = new AnimalDetails(); var medDataId = Int32.Parse(_animalMedicalDataService.Get(amd => amd.Id_animal == id.ToString()).OrderBy(z => z.CreatedOnUtc).LastOrDefault().Id_MedicalData); if (medDataId != null) { MedicalData medicalData = _medicalDataService.Get(x => x.Id == medDataId).FirstOrDefault(); model.HairType = medicalData.Hair; model.Race = medicalData.Race; } Animal a = _animalService.Get(x => x.Id == id).FirstOrDefault(); model.Age = a.Age; model.Birthday = a.Birthday; model.Character = a.Character; model.nom = a.Name; model.Pedigree = a.Pedigree; model.Price = a.Price; model.Robe = a.Robe; model.sexe = a.Sexe; model.Type = a.Type; model.Weight = a.Weight; return(View()); }
public async Task <ActionResult <AnimalDetails> > PostAnimalDetails(AnimalDetails animalDetails) { _context.AnimalDetails.Add(animalDetails); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAnimalDetails", new { id = animalDetails.AnimalId }, animalDetails)); }
public async Task <IActionResult> PutAnimalDetails(int id, AnimalDetails animalDetails) { if (id != animalDetails.AnimalId) { return(BadRequest()); } _context.Entry(animalDetails).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnimalDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// Retrieve all info for all animals in Zoo // return a BindingList ready for View! public List <AnimalDetails> GetAllAnimalsInSublist(List <Animal> anim) { var animals = new List <AnimalDetails>(); using (var db = new ZooContext()) { AnimalDetails animalView; var filteredAnimalList = from first in anim from second in db.Animals where first.AnimalId == second.AnimalId select first; foreach (var animal in filteredAnimalList) { animalView = new AnimalDetails(); animalView.Id = animal.AnimalId; // PK of Animals ! animalView.Name = animal.Name; animalView.Weight = animal.Weight; // Search for possible parents and store in a list if (animal.IsChildOf.Count() != 0) { if (animal.IsChildOf.ToList().Count() == 1) { animalView.Parent1 = animal.IsChildOf.ToList()[0].Parent.Name; animalView.Parent2 = "Not available"; // Missing one parent } else { animalView.Parent1 = animal.IsChildOf.ToList()[0].Parent.Name; animalView.Parent2 = animal.IsChildOf.ToList()[1].Parent.Name; } } else { // there are no parents for the current animal animalView.Parent1 = "Not available"; // Missing one parent animalView.Parent2 = "Not available"; // Missing one parent } animalView.HabitatType = animal.Habitat.Name; animalView.DietType = animal.Diet.Name; animalView.OriginCountry = animal.Origin.Name; animalView.SpeciesType = animal.Species.Name; animals.Add(animalView); } } return(animals); }
// Retrieve all info for all animals in Zoo // return a BindingList ready for View! public BindingList <AnimalDetails> GetAnimalDetails() { var animals = new BindingList <AnimalDetails>(); using (var db = new ZooContext()) { AnimalDetails animalView; foreach (var animal in db.Animals) { animalView = new AnimalDetails(); animalView.Id = animal.AnimalId; // PK of Animals ! animalView.Name = animal.Name; animalView.Weight = animal.Weight; // Search for possible parents and store in a list if (animal.IsChildOf.Count() != 0) { if (animal.IsChildOf.Count() == 1) { animalView.Parent1 = animal.IsChildOf.ToList()[0].Parent.Name; animalView.Parent2 = "Not available"; // Missing one parent } else { animalView.Parent1 = animal.IsChildOf.ToList()[0].Parent.Name; animalView.Parent2 = animal.IsChildOf.ToList()[1].Parent.Name; } } else { // there are no parents for the current animal animalView.Parent1 = "Not available"; // Missing one parent animalView.Parent2 = "Not available"; // Missing one parent } animalView.HabitatType = animal.Habitat.Name; animalView.DietType = animal.Diet.Name; animalView.OriginCountry = animal.Origin.Name; animalView.SpeciesType = animal.Species.Name; animals.Add(animalView); } } return(animals); }
public IHttpActionResult LiveStockMethod(int LiveStockID, int BreedId, int MilkAmount, string Mode, string version) { try { DataSet ds = new DataSet(); ds = LiveStocks.GetLiveStock(LiveStockID, BreedId, MilkAmount, Mode, version); ds.Tables[0].TableName = "LiveStockDetails"; ds.Tables[1].TableName = "AnimalDetails"; DataSet ds1 = new DataSet(); ds1 = LiveStocks.BZTrendsProducts("1", "", ""); // ds1 = LiveStocks.BZLiveStockProducts("1"); ds1.Tables[0].TableName = "Products"; ds.Tables.Add(ds1.Tables[0].Copy()); BALLiveStock objLiveStock = new BALLiveStock(); List <BALLiveStock> ListLiveStock = new List <BALLiveStock>(); var liveStockData = ds.Tables[0].AsEnumerable(); var liveStockProduct = ds1.Tables[0].AsEnumerable(); AnimalDetails objAnimal = new AnimalDetails(); objAnimal.LiveStockId = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["LiveStockId"]); objAnimal.LiveStockName = ds.Tables["AnimalDetails"].Rows[0]["LiveStockName"].ToString(); objAnimal.LiveStockNameHindi = ds.Tables["AnimalDetails"].Rows[0]["LiveStockNameHindi"].ToString(); objAnimal.LiveStockType = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["LiveStockType"]); objAnimal.BreedId = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["BreedId"]); objAnimal.BreedName = Convert.ToString(ds.Tables["AnimalDetails"].Rows[0]["BreedName"]); objAnimal.IsMilk = Convert.ToBoolean(ds.Tables["AnimalDetails"].Rows[0]["IsMilk"]); objAnimal.MilkQuantity = Convert.ToInt32(ds.Tables["AnimalDetails"].Rows[0]["MilkQuantity"]); objAnimal.IsActive = Convert.ToBoolean(ds.Tables["AnimalDetails"].Rows[0]["IsActive"]); objAnimal.ImageUrl = ds.Tables["AnimalDetails"].Rows[0]["ImageUrl"].ToString(); objAnimal.BALLiveStock = new List <BALLiveStock>(); foreach (var item in liveStockData) { objAnimal.BALLiveStock.Add(new BALLiveStock { ID = item.Field <int>("ID"), Name = item.Field <string>("Name"), Description = item.Field <string>("Description"), Extra = item.Field <int>("Extra"), IsShow = item.Field <bool>("IsShow"), VideoUrl = item.Field <string>("VideoUrl"), ImageUrl = item.Field <string>("ImageUrl"), Products = new List <Products>() }); } foreach (var ItemList in objAnimal.BALLiveStock) { foreach (var item1 in liveStockProduct) { if (item1.Field <long>("RowNumber") > 1) { ItemList.Products.Add(new Products { RowNumber = item1.Field <long>("RowNumber"), ProductID = item1.Field <int>("ProductID"), ProductName = item1.Field <string>("ProductName"), OrganisationName = item1.Field <string>("OrganisationName"), BrandName = item1.Field <string>("BrandName"), TechnicalName = item1.Field <string>("TechnicalName"), SubCategoryName = item1.Field <string>("SubCategoryName"), CategoryName = item1.Field <string>("CategoryName"), CategoryHindi = item1.Field <string>("CategoryHindi"), CategoryID = item1.Field <byte>("CategoryID"), PackageID = item1.Field <int>("PackageID"), RN = item1.Field <Int64>("RN"), OfferPrice_Qty = item1.Field <int?>("OfferPrice_Qty"), Amount = item1.Field <decimal>("Amount"), UnitName = item1.Field <string>("UnitName"), OurPrice = item1.Field <decimal>("OurPrice"), offerprice = item1.Field <decimal>("offerprice"), RecordID = item1.Field <int>("RecordID"), CreatedDate = item1.Field <DateTime>("CreatedDate"), IsActive = item1.Field <bool>("IsActive"), status = item1.Field <string>("status"), CretedBy = item1.Field <string>("CretedBy"), ProductHindiName = item1.Field <string>("ProductHindiName"), IsDetails = item1.Field <bool>("IsDetails"), ImagePath = item1.Field <string>("ImagePath"), DistrictID = item1.Field <int>("DistrictID"), DistrictName = item1.Field <string>("DistrictName"), COD = item1.Field <decimal>("COD"), OnlinePrice = item1.Field <decimal>("OnlinePrice"), MRP = item1.Field <decimal>("MRP"), OfferDiscount = item1.Field <string>("OfferDiscount") + " छूट" }); } } } return(Ok(new { LiveStockResults = objAnimal, Status = true })); } catch (Exception ex) { LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0); return(Ok(new { LiveStockResults = "", Status = false })); } }