public ActionResult <PetType> Post([FromBody] PetType newPetType) { try { return(StatusCode(201, _petTypeService.Createtype(newPetType))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <PetType> Put(int id, [FromBody] PetType petType) { try { return(StatusCode(202, _petTypeService.UploadPetTypeByID(id, petType))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public PetType EditPetType(int idOfPetTypeToEdit, PetType editedPetType) { if (!_petTypeRepository.GetAllPetTypes().Exists(x => x.ID == idOfPetTypeToEdit)) { throw new KeyNotFoundException("A pet with this ID does not exist"); } else { return(_petTypeRepository.EditPetType(idOfPetTypeToEdit, editedPetType)); } }
public PetType Update(int index, PetType petType) { try { return(_ptrep.Update(index, petType)); } catch (Exception e) { throw new ServiceException("Error updating pet type: " + e.Message, e); } }
public PetDTO(int id, string name, PetType petType, DateTime birthDate, DateTime soldDate, string color, Owner previousOwner, double price) { ID = id; Name = name; PetType = petType; BirthDate = birthDate; SoldDate = soldDate; Color = color; PreviousOwner = previousOwner; Price = price; }
public PetType Add(PetType petType) { try { return(_ptrep.Add(petType)); } catch (Exception e) { throw new ServiceException("Error adding pet type: " + e.Message, e); } }
public ActionResult Update(PetType petType) { if (ModelState.IsValid) { db.Entry(petType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(petType)); }
public ActionResult Create(PetType petType) { if (ModelState.IsValid) { db.PetTypes.Add(petType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(petType)); }
public PetType Update(PetType petTypeUpdate) { var petTypeFromDB = ReadById(petTypeUpdate.Id); if (petTypeFromDB != null) { petTypeFromDB.Type = petTypeUpdate.Type; return(petTypeFromDB); } return(null); }
private async ValueTask <bool> HandleSetPet(ClientPlayer sender, PetType pet) { if (_game.GameState == GameStates.Started && await sender.Client.ReportCheatAsync(RpcCalls.SetPet, "Client tried to change pet while not in lobby")) { return(false); } PlayerInfo.Pet = pet; return(true); }
public PetType UpdatePetType(PetType type) { PetType petType = ((List <PetType>)PetTypes).Find((x) => { return(x.ID == type.ID); }); if (petType != null) { petType.Name = type.Name; return(petType); } return(null); }
public PetType DeletePetType(int ID) { PetType petType = PetTypes.Where((x) => { return(x.ID == ID); }).FirstOrDefault(); if (petType != null) { ((List <PetType>)PetTypes).Remove(petType); return(petType); } return(null); }
private void AddPet(string name, Owner owner, PetType petType, string race) { _dataContext.Pets.Add(new Pet { Born = DateTime.Now.AddYears(-2), Name = name, Owner = owner, PetType = petType, Race = race }); }
public async Task <IActionResult> Create([Bind("Id,Name")] PetType petType) { if (ModelState.IsValid) { _context.Add(petType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(petType)); }
public ActionResult Create([Bind(Include = "PetTypeID,PetTypeName")] PetType petType) { if (ModelState.IsValid) { db.PetType.Add(petType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(petType)); }
public ActionResult <PetType> Put(int id, [FromBody] PetType pettype) { try { return(Accepted(petTypeService.updatePet(id, pettype))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public PetType UploadPetTypeByID(int id, PetType petType) { if (id < 0) { throw new Exception("Please, enter a valid value for the ID"); } else if (petType == null) { throw new Exception("Please, include the new Pet Type"); } return(_petTypeRepo.UploadPetTypeByID(id, petType)); }
/// <summary> /// Get pets for owners of a particular gender /// </summary> /// <param name="gender">Pet Owner gender</param> /// <param name="petType">Type of Owner pet</param> /// <returns></returns> public List <Pet> GetPetsByOwnerGenderAndPetType(Gender gender, PetType petType) { var genderStr = gender.ToString(); var petTypeStr = petType.ToString(); return(PeopleList .Where(person => person.Gender.ToString() == genderStr && person.Pets?.Count > 0) .SelectMany(person => person.Pets) .Where(pet => pet.Type.ToString() == petTypeStr) .OrderBy(pet => pet.Name) .ToList()); }
public static IPet CreatePet(PetType type) { switch (type) { case PetType.Cat: return new Cat(); case PetType.Dog: return new Dog(); default: return null; } }
public bool UpdatePetType(PetType type) { var ListIndex = petTypes.FindIndex(x => x.Id == type.Id); if (ListIndex == -1) { throw new KeyNotFoundException($"pet type with id {type.Id} doesnt exist"); } petTypes[ListIndex] = type; return(true); }
public List <Pet> SearchByType(PetType petType) { try { List <Pet> result = _prep.GetAll().Where(pet => pet.Type.Equals(petType)).ToList(); return(result); } catch (Exception e) { throw new ServiceException("Error getting pet by type: " + e.Message, e); } }
// Remove later for UOW public PetType UpdatePetType(PetType petTypeUpdate) { var petTypeFromDB = this.ReadById(petTypeUpdate.petTypeId); if (petTypeFromDB != null) { petTypeFromDB.name = petTypeUpdate.name; return(petTypeFromDB); } return(null); }
public PetType CreatePetType(PetType petType) { if (petType.Pet == null || petType.Pet.Id <= 0) { throw new InvalidDataException("To create pet type you need a pet"); } if (_petRepo.ReadById(petType.Pet.Id) == null) { throw new InvalidDataException("Pet type not found"); } return(_petTypeRepo.Create(petType)); }
public ActionResult <PetType> Post([FromBody] PetType value) { try { return(string.IsNullOrEmpty(value.name) ? BadRequest("Name is required to create a petType") : StatusCode(201, _petTypeService.CreatePetType(value))); } catch (Exception e) { Console.WriteLine(e); return(StatusCode(500, e)); } }
public PetType DeletePetType(Guid typeID) { PetType dbEntry = context.PetTypes .FirstOrDefault(p => p.TypeID == typeID); if (dbEntry != null) { context.PetTypes.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public void Add(PetType petType) { var sql = @"INSERT INTO [PetType] ([Type],[isActive]) OUTPUT inserted.Id VALUES(@Type, @isActive)"; using var db = new SqlConnection(ConnectionString); var id = db.ExecuteScalar <int>(sql, petType); petType.Id = id; }
public ActionResult <PetType> Post([FromBody] PetType petType) { try { _petTypeService.AddNewPetType(petType); return(petType); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public async Task <IActionResult> PostPetType([FromBody] PetType petType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PetTypes.Add(petType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPetType", new { id = petType.Id }, petType)); }
private void AddPet(string name, Customer owner, PetType petType, string race) { _context.Pets.Add(new Pet { Born = DateTime.Now.AddYears(-2), Name = name, Customer = owner, PetType = petType, Race = race, Remarks = "Welcome to YourVet!!" }); }
public BasePet GetPet(PetType _type) { if (_type == PetType.BlueBaBaType) { return(this.blueBaBa); } if (_type == PetType.RedBaBaType) { return(this.redBaBa); } return(null); }
public PetType AddPetType(PetType type) { if (type != null) { if ((from x in GetAllPetTypes() where x.Name.ToLower().Equals(type.Name.ToLower()) select x).Count() > 0) { throw new ArgumentException("Pet type with that name already exists"); } return(PetTypeRepository.AddPetType(type)); } return(null); }
private int PetNumberProvider(PetType pet) { int retPet = 0; switch (pet) { case PetType.worm: { retPet = 7; } break; //выпустить синего духа case PetType.wormBlueSoul: { retPet = 16; } break; //выпустить кита case PetType.whale: { retPet = 21; } break; //выпустить попоугая case PetType.parot: { retPet = 23; } break; default: break; } return retPet; }
/// <summary> /// There are no comments for DogPetType in the schema. /// </summary> public void AddToDogPetType(PetType petType) { base.AddObject("DogPetType", petType); }
/// <summary> /// Create a new PetType object. /// </summary> /// <param name="petTypeId">Initial value of PetTypeId.</param> public static PetType CreatePetType(int petTypeId) { PetType petType = new PetType(); petType.PetTypeId = petTypeId; return petType; }
/// <summary> /// There are no comments for CatPetType in the schema. /// </summary> public void AddToCatPetType(PetType petType) { base.AddObject("CatPetType", petType); }
public Druid(PetType type) { pet = new druidPet(type); }
public Pet(string name,string age,PetType type) { Name = name; Age = age; PetType = type; }
public rangerPet(PetType type, PetSize size) { petType = type; petSize = size; }
public wizardFamilar(PetType type) { petType = type; }
public druidPet(PetType type) { petType = type; }
private void GetPet(PetType pet = PetType.currentPet) { try { //если есть линка посадить в клетку, то проверяем на правильность зверя if (driver.FindElement(By.XPath("//a[@title='Посадить в клетку']")).Displayed == true) { //если зверь не дефолтный, то сверяем текущего зверя с нужным if (PetNumberProvider(pet) != 0) { string css = string.Format(".pet{0}", PetNumberProvider(pet)); //Если нет иконки нужного зверя попадаем в кетч и садим невалидного зверя в клетку,а нужного достаем try { IWebElement temp = driver.FindElement(By.CssSelector(css)); } catch { SetPet(); //Деревня driver.FindElement(By.Id("m3")).FindElement(By.XPath(".//b")).Click(); Delays(); //Жилище driver.FindElement(By.LinkText("Жилище")).Click(); Delays(); //клетка driver.FindElement(By.LinkText("Клетка")).Click(); Delays(); //вытащить с клетки if (PetNumberProvider(pet) == 0) { driver.FindElement(By.XPath("//input[@value='ВЫПУСТИТЬ ИЗ КЛЕТКИ']")).Click(); } else { try { string xPath = string.Format("//img[contains(@src,'Pet_{0}')]/ancestor::div[contains(@class,'round_block_round_border')]//input[contains(@value,'ВЫПУСТИТЬ')]", PetNumberProvider(pet)); driver.FindElement(By.XPath(xPath)).Click(); Delays(); } catch { string xPath = string.Format("//img[contains(@src,'Pet_{0}s')]/..//input[@value='ВЗЯТЬ В БОЙ']", PetNumberProvider(pet)); driver.FindElement(By.XPath(xPath)).Click(); Delays(); }; } } } } } //проверка есть ли зверь catch { //Деревня driver.FindElement(By.Id("m3")).FindElement(By.XPath(".//b")).Click(); Delays(); //Жилище driver.FindElement(By.LinkText("Жилище")).Click(); Delays(); //клетка driver.FindElement(By.LinkText("Клетка")).Click(); Delays(); //вытащить с клетки if (PetNumberProvider(pet) == 0) { driver.FindElement(By.XPath("//input[@value='ВЫПУСТИТЬ ИЗ КЛЕТКИ']")).Click(); } else { try { string xPath = string.Format("//img[contains(@src,'Pet_{0}')]/ancestor::div[contains(@class,'round_block_round_border')]//input[contains(@value,'ВЫПУСТИТЬ')]", PetNumberProvider(pet)); driver.FindElement(By.XPath(xPath)).Click(); Delays(); } catch { string xPath = string.Format("//img[contains(@src,'Pet_{0}s')]/..//input[@value='ВЗЯТЬ В БОЙ']", PetNumberProvider(pet)); driver.FindElement(By.XPath(xPath)).Click(); Delays(); }; } } }