public void UpdatePet() { var function = new FunctionCreatePet(); var context = new TestLambdaContext(); var requestUser = new PetModel { Name = "Tati 3", PetType = PetType.Cat, IdOwner = "LAZzUWoBfKkxXf3ErZ77", OwnerType = PersonType.PF, Description = "Achei na rua", PetAge = PetAge.Adult, Color = "Listrado", Id = "MgYZiWoBfKkxXf3EE55r" }; var apiGateway = new APIGatewayProxyRequest { HttpMethod = "PUT", Path = "create-pet", Body = JsonConvert.SerializeObject(requestUser), Headers = new Dictionary <string, string>() { { "Content-Type", "application/json" } } }; var _return = function.FunctionHandler(apiGateway, context); Assert.Equal(200, _return.StatusCode); }
public PetsMapsView(PetModel petSelected) { InitializeComponent(); petSelected.ImageBase64 = new ImageService().SaveImageFromBase64(petSelected.ImageBase64, petSelected.ID); MapPets.Pet = petSelected; MapPets.MoveToRegion( MapSpan.FromCenterAndRadius( new Position( petSelected.Latitude, petSelected.Longitude ), Distance.FromMiles(.5) ) ); MapPets.Pins.Add( new Pin { Type = PinType.Place, Label = petSelected.Name, Position = new Position( petSelected.Latitude, petSelected.Longitude ) } ); PetName.Text = petSelected.Name; PetAge.Text = petSelected.Age.ToString(); PetBreed.Text = petSelected.Breed; }
public static int Create(int itemid, MapleCharacter chr) { try { MapleItemInformationProvider mii = MapleItemInformationProvider.Instance; using (var db = new NeoMapleStoryDatabase()) { var petmodel = new PetModel() { Name = mii.GetName(itemid), Level = 1, Closeness = 0, Fullness = 100, UniqueId = MapleCharacter.GetNextUniqueId() }; db.Pets.Add(petmodel); db.SaveChanges(); chr.Save(); return(petmodel.Id); } } catch (Exception e) { Console.WriteLine(e); return(-1); } }
public PetModel UpdatePet(int PetId, PetModel petModel) { petModel.Id = PetId; var petToUpdate = _refugeRepository.UpdatePet(_mapper.Map <PetEntity>(petModel)); return(_mapper.Map <PetModel>(petToUpdate)); }
public Pet(PetModel model) { PetImages = new List <PetImage>(); Id = model.Id; UserId = model.UserId; Name = model.Name; Sex = model.Sex; Description = model.Description; Breed = model.Breed; Weight = model.Weight; Years = model.Years; Months = model.Months; Spayed = model.Spayed; Microchipped = model.Microchipped; WellDogs = model.WellDogs; WellDogDetail = model.WellDogDetail; WellCats = model.WellCats; WellCatDetail = model.WellCatDetail; WellChild = model.WellChild; WellChildDetail = model.WellChildDetail; HouseTrained = model.HouseTrained; HouseTrainedDetail = model.HouseTrainedDetail; SpecialRequirement = model.SpecialRequirement; }
public PetsMapsView(PetModel petSelected) { InitializeComponent(); // Centra el mapa con las coordenadas de la mascota MapPets.MoveToRegion( MapSpan.FromCenterAndRadius( new Position( petSelected.Latitude, petSelected.Longitude ), Distance.FromMiles(.5) ) ); // Agrega un pin al mapa con las coordenadas de la mascota MapPets.Pins.Add( new Pin { Type = PinType.Place, Label = petSelected.Name, Position = new Position( petSelected.Latitude, petSelected.Longitude ) } ); // Enviamos los datos de la mascota en el cuadro de texto blanco PetName.Text = petSelected.Name; PetAge.Text = petSelected.Age.ToString(); PetBreed.Text = petSelected.Breed; }
/// <summary> /// Save pet and create a new form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bbiSaveAndNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { String image = ""; String fromPath = openDialog.FileName; String oldPath = openDialog.FileName; if (!string.IsNullOrEmpty(p_imageTextEdit.Text)) { PetModel pm = new PetModel(); //if (openDialog.FileName.EndsWith(".jpg")) { p_imageTextEdit.Text = pm.SetPetID() + ".jpg"; } //else { p_imageTextEdit.Text = pm.SetPetID() + ".png"; } //Get solution App path String projectPath = Path.GetFullPath(Path.Combine(Application.StartupPath, "..\\..")); //Get current application direction Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); //get image path String newFilePath = Path.GetFullPath(projectPath + "\\img\\" + p_imageTextEdit.Text); //get solution Web path String solutionWebPath = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName; FileInfo fi = new FileInfo(newFilePath); if (!fi.Exists) { //File.Delete(newFilePath); //Copy file to image folder on Apps File.Copy(oldPath, @"../../img/" + p_imageTextEdit.Text); //copy file to image folder on Web File.Copy(oldPath, solutionWebPath + "\\PetStoreWebClient\\Assets\\images\\" + p_imageTextEdit.Text); } } //Set time publish p_publishedDateEdit.Text = DateTime.Now.ToString(); }
public ActionResult <PetModel> UpdatePet(int petId, [FromBody] PetModel petModel) { try { if (!ModelState.IsValid) { foreach (var pair in ModelState) { if (pair.Key == nameof(petModel.Description) && pair.Value.Errors.Count > 0) { return(BadRequest(pair.Value.Errors)); } } } return(_petService.UpdatePet(petId, petModel)); } catch (NotFoundException ex) { return(NotFound(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}")); } }
public PetMapPage(PetModel petSelected) { InitializeComponent(); MapPet.MoveToRegion( MapSpan.FromCenterAndRadius( new Position(petSelected.Latitude, petSelected.Longitude), Distance.FromMiles(.5) )); string imagePath = new ImageService().SaveImageFromBase64(petSelected.ImageBase64, petSelected.Id); petSelected.ImageBase64 = imagePath; MapPet.Pet = petSelected; MapPet.Pins.Add( new Pin { Type = PinType.Place, Label = petSelected.Name, Position = new Position(petSelected.Latitude, petSelected.Longitude) } ); Name.Text = petSelected.Name; Age.Text = (DateTime.Now.Year - petSelected.BornDate.Year).ToString() + " años"; Notes.Text = petSelected.Notes; }
public async Task <List <PetModel> > Pets() { List <PetModel> list = new List <PetModel>(); var data = await ParseObject.GetQuery("Pets").WhereEqualTo("user", ParseUser.CurrentUser).FindAsync(); foreach (ParseObject obj in data) { var model = new PetModel() { User = ParseUser.CurrentUser, Name = obj.Get <string>("name"), Kind = obj.Get <string>("kind"), Breed = obj.Get <string>("breed"), BirthDate = obj.Get <DateTime>("birthdate"), Picture = (obj.ContainsKey("picture") == true && obj["picture"] != null) ? obj.Get <ParseFile>("picture") : null }; model.ObjectId = obj.ObjectId; model.Logo = (model.Picture != null) ? model.Picture.Url.OriginalString : PetHelper.PetImage(model.Kind); list.Add(model); } return(list); }
public PetModel AddOrUpdate(PetModel pet) { if (pet.Id == 0) { _db.Pets.Add(new Pet() { Breed = pet.Breed, BirthDate = pet.BirthDate, IsDeleted = false, Name = pet.Name, OwnerId = pet.OwnerId, Species = pet.Species }); } else { var dbPet = _db.Pets.SingleOrDefault(p => p.Id == pet.Id); if (dbPet == null) { throw new Exception(); } dbPet.Breed = pet.Breed; dbPet.BirthDate = pet.BirthDate; dbPet.Name = pet.Name; dbPet.OwnerId = pet.OwnerId; dbPet.Species = pet.Species; } _db.SaveChanges(); return(pet); }
public void InsertPet(PetModel pet) { pet.IdPet = Guid.NewGuid(); dbContext.Pets.InsertOnSubmit(MapModelToDbObject(pet)); dbContext.SubmitChanges(); }
public async Task CreatePet() { try { string base64ToString = Convert.ToBase64String(memoryStream.ToArray()); memoryStream = new MemoryStream(); PetModel pet = new PetModel() { Name = PetName, IdSpecie = Species[PetIndexSpecie].IdSpecie, GeneralInfo = PetGeneralInfo, Birthdate = PetBirthdate, IdClient = Convert.ToInt64(Settings.UId), ImagePath = base64ToString }; APIResponse response = await PostPet.ExecuteStrategy(pet); if (response.IsSuccess) { await NavigationService.PopPage(); } } catch (Exception e) { } }
public async Task <Response> Create(PetModel pet) { if (pet == null) { return(new Response(Result.BadRequest, new Metadata(Link.Self($"{Constants.TOKENIZED_CURRENT_URL}", HttpMethod.Post.Method)), $"Parameter cannot be null : owner")); } if (string.IsNullOrEmpty(pet.Id)) { return(new Response(Result.BadRequest, new Metadata(Link.Self($"{Constants.TOKENIZED_CURRENT_URL}", HttpMethod.Post.Method)), $"Parameter cannot be null : owner.id")); } var metadata = new Metadata(new[] { Link.Self($"{Constants.TOKENIZED_CURRENT_URL}", HttpMethod.Post.Method), Link.Custom("detail", $"{Constants.TOKENIZED_CURRENT_URL}/{pet.Id}/detail", HttpMethod.Get.Method), Link.Edit($"{Constants.TOKENIZED_CURRENT_URL}/{pet.Id}", HttpMethod.Put.Method), Link.Delete($"{Constants.TOKENIZED_CURRENT_URL}/{pet.Id}", HttpMethod.Delete.Method), }); try { var petEntity = Mapper.Map <PetEntity>(pet); var added = await PetRepository.Add(petEntity); return(new Response(Result.Created, metadata)); } catch (DataException <PetEntity> ex) { return(new Response(ex.Result, metadata, $"{ex.Message}")); } catch (Exception ex) { return(new Response(Result.InternalError, metadata, $"{ex.GetBaseException().Message}")); } }
private void p_idTextEdit_Click(object sender, EventArgs e) { PetModel pm = new PetModel(); p_idTextEdit.Text = pm.SetPetID(); p_statusTextEdit.SelectedItem = "Active"; }
public ActionResult Search(string keywordPet, int page = 1, int pageSize = 2) { var productView = new ProductViewHome(); //initialize int totalRecord = 0; //Save Pet to pass data to another view ViewBag.viewPetSaleOff = productView.getViewPetSaleOff(); //Get all pet var allPet = new PetModel().Search(keywordPet, ref totalRecord, page, pageSize); //Save total page, keyword and page to pass data to another view ViewBag.Total = totalRecord; ViewBag.keyword = keywordPet; ViewBag.Page = page; //Paging int maxPage = 5;//maximum page link display on website int totalPage = 0; //Paging Algorithm totalPage = (int)Math.Ceiling((double)totalRecord / pageSize); //Save data page to pass data to another view ViewBag.totalPage = totalPage; ViewBag.maxPage = maxPage; ViewBag.first = 1; ViewBag.last = totalPage; ViewBag.next = page + 1; ViewBag.prev = page - 1; return(View(allPet)); }
/// <summary> /// Open dialog and allow user choose image /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void p_imageTextEdit_Click(object sender, EventArgs e) { //The Filter in open dialog will only accept file .jpg and .png openDialog.Filter = "Image files (*.jpg)|*.jpg|Image files (*.png)|*.png|All files (*.*)|*.*"; openDialog.ShowDialog(); //if file choosen is not empy and is image file //then set image name for image file if (openDialog.FileName != "" && (openDialog.FileName.EndsWith(".jpg") || openDialog.FileName.EndsWith(".png"))) { p_imageTextEdit.Text = openDialog.FileName; PetModel pm = new PetModel(); //set name image file is Pet's ID appends .jpg or .png if (openDialog.FileName.EndsWith(".jpg")) { p_imageTextEdit.Text = pm.SetPetID() + ".jpg"; } else { p_imageTextEdit.Text = pm.SetPetID() + ".png"; } } else { XtraMessageBox.Show("Please choose a image with (*.jpg)/(*.png) file !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public MapPage(PetModel petSelected) { InitializeComponent(); // aqui aparece el punto guardado MapPet.MoveToRegion( MapSpan.FromCenterAndRadius( new Position(petSelected.Latitude, petSelected.Longitude), Distance.FromMiles(.5) )); string imagePath = new ImageService().SaveImageFromBase64(petSelected.ImageBase64); petSelected.ImageBase64 = imagePath; MapPet.Pet = petSelected; //añadir el punto en el mapa MapPet.Pins.Add( new Pin { Type = PinType.Place, Label = petSelected.Name, Position = new Position( petSelected.Latitude, petSelected.Longitude) } ); Name.Text = petSelected.Name; BirthDate.Text = petSelected.BirthDate.ToShortDateString(); Comments.Text = petSelected.Comments; }
public ActionResult AddDog() { var model = new PetModel(); model.UserId = User.Identity.GetUserId(); return(View(model)); }
public MarkerWindow(PetModel pet) { this.InitializeComponent(); MarkerWindowImage.ImageSource = new BitmapImage(new Uri(pet.ImageBase64)); MarkerWindowTitle.Text = pet.Name; MarkerWindowNotes.Text = pet.Direction; }
public async Task <bool> AddPet(PetModel model) { _dbContext.Pets.Add(model); var result = await _dbContext.SaveChangesAsync(); return(result > 0); }
private static string IsGood(PersonModel person, PetModel pet) { int count = 0; if (person.PreferredPetType == pet.Type) { count++; } if (person.PreferredClassification == pet.Classification) { count++; } if (person.PetSize == pet.Size) { count++; } if (count == 3) { return("best"); } if (count == 2) { return("great"); } if (count == 1) { return("good"); } else { return("bad"); } }
public async Task <bool> UpdatePetInformation(PetModel originalModel, PetModel modelToUpdate) { _dbContext.Entry(originalModel).CurrentValues.SetValues(modelToUpdate); var result = await _dbContext.SaveChangesAsync(); return(result > 0); }
public async Task <bool> SuscribePet(PetViewModel viewModel, HttpPostedFileBase photo, DirectoryInfo route) { PetModel model = new PetModel { Name = viewModel.petName, LastName = viewModel.petLastName, Age = viewModel.petAge, Type = viewModel.petType, Gender = viewModel.petGender, Breed = viewModel.petBreed, Color = viewModel.petColor, OwnerId = viewModel.OwnerId }; if (photo != null) { if ((photo.ContentType.Equals("image/jpeg") || photo.ContentType.Equals("image/png")) && photo.ContentLength <= 2000000) { string photoName = Path.GetFileName(photo.FileName); string path = Path.Combine(route.FullName, photoName); photo.SaveAs(path); model.PhotoURL = viewModel.petPhotoURL; } } return(await _repository.AddPet(model)); }
public async Task <ActionResult <bool> > CreatePetAsync(PetViewModel createPet) { PetModel pet = _mapper.MapObjectTo <PetModel>(createPet); bool isCreated = await _petService.CreatePetAsync(pet); return(isCreated ? Created(Url.Action(nameof(GetPetById), new { id = pet.Id }), _mapper.MapObjectTo <PetViewModel>(pet)) as ActionResult : BadRequest() as ActionResult); }
public PetModel AddOrEditPet(PetModel model, OwnerModel ownerModel) { OwnerService ownerLogic = new OwnerService(); var owner = ownerLogic.AddOrEditOwner(ownerModel); Pet pet = new Pet(); using (var db = new PawsAndClawsEntities()) { pet = db.Pets.Where(i => i.PetId == model.PetId).FirstOrDefault(); if (pet != null) { pet.PetName = model.PetName; pet.Type = model.Type; pet.OwnerId = model.OwnerId; } else { model.OwnerId = owner.OwnerId; pet = db.Pets.Add(model.ToDTO()); } db.SaveChanges(); } return(new PetModel(pet)); }
public async void SendEmail(PetModel pet, string vetName, string vetEmail) { EmailRecipient sendTo = new EmailRecipient() { Address = vetEmail }; EmailMessage mail = new EmailMessage(); mail.Subject = "Petmergency - " + ParseUser.CurrentUser["nameSurname"] + " size bir soru sordu !"; if (pet == null) { mail.Body = "Merhaba " + vetName + " !" + "\n\n" + "Size aşağıdaki soruyu sormak istiyorum." + "\n\n" + "Sorunuz : " + "\n\n" + "Bu e-posta Petmergency uygulaması aracılığı ile iletilmiştir." + "\n\n"; } else { mail.Body = "Merhaba " + vetName + " !" + "\n\n" + "Size aşağıdaki soruyu sormak istiyorum." + "\n\n" + "Sorunuz : " + "\n\n" + "Küçük dostumun bilgileri:" + "\n" + "Adı:" + pet.Name + "\n" + "Doğum Tarihi:" + pet.BirthDate.Date.ToString("dd/MM/yyyy") + "\n" + "Irkı:" + pet.Kind + "\n" + "Cinsi:" + pet.Breed + "\n\n" + "Bu e-posta Petmergency uygulaması aracılığı ile iletilmiştir." + "\n\n"; } mail.To.Add(sendTo); await EmailManager.ShowComposeNewEmailAsync(mail); }
private void PetStaff_Load(object sender, EventArgs e) { PetModel pm = new PetModel(); bsPet.DataSource = pm.getAllPet(); gcPet.DataSource = bsPet; }
public async Task <Response> Update(PetModel pet) { if (pet == null) { return(new Response(Result.BadRequest, new Metadata(Link.Self($"{Constants.TOKENIZED_CURRENT_URL}", HttpMethod.Put.Method)), $"Parameter cannot be null : owner")); } var metadata = new Metadata(new[] { Link.Self($"{Constants.TOKENIZED_CURRENT_URL}", HttpMethod.Put.Method), Link.Custom("detail", $"{Constants.TOKENIZED_CURRENT_URL}/{pet.Id}/detail", HttpMethod.Get.Method), Link.Delete($"{Constants.TOKENIZED_CURRENT_URL}/{pet.Id}", HttpMethod.Delete.Method), }); try { var petEntity = Mapper.Map <PetEntity>(pet); var updated = await PetRepository.Update(petEntity); if (!updated) { return(new Response(Result.NotFound, new Metadata(Link.Self($"{Constants.TOKENIZED_CURRENT_URL}", HttpMethod.Put.Method)), $"No Pet exists with the ID : {pet.Id}")); } return(new Response(Result.Updated, metadata)); } catch (DataException <PetEntity> ex) { return(new Response(ex.Result, metadata, $"{ex.Message}")); } catch (Exception ex) { return(new Response(Result.InternalError, metadata, $"{ex.GetBaseException().Message}")); } }
//Constructores public PetsViewModel() { PetSelected = new PetModel(); Pets = new List <PetModel>(); PetsList = new ObservableCollection <PetModel>(); InitializeRequest(); InitializeCommands(); }