public FilmController(AddFilm addFilm, GetPhoto getPhoto, GetAllFilms getAllFilms, GetMyFilms getMyFilms, GetFilmToId getFilmToId, DeleteFilmToId deleteFilmToId) { _addFilm = addFilm; _getPhoto = getPhoto; _getAllFilms = getAllFilms; _getMyFilms = getMyFilms; _getFilmToId = getFilmToId; _deleteFilmToId = deleteFilmToId; }
/// <summary> /// Gets the image from the database, checks ID for integer type. /// </summary> /// <param name="photoID">string value of photoid</param> /// <param name="getPhotoMethod">Method to retreive photo</param> /// <returns>byte array of image.</returns> private static byte[] GetImage(string photoID, GetPhoto getPhotoMethod) { //declare image container byte[] image = new byte[128]; //local id variable int imageId; //test string for type of int, if it is assign it to the imageID if (int.TryParse(photoID, out imageId)) { //Retreive image with delegate method image = getPhotoMethod(imageId); } return(image); }
public async Task <ActionResult <IEnumerable <Note> > > Get() { var userId = HttpContext.User.GetUserId(); List <NoteDto> noteDtos = await _notesCollection.Find(note => note.UserId == userId).ToListAsync(); string googleAccessToken = HttpContext.Request.Headers["googleAccessToken"]; foreach (NoteDto noteDto in noteDtos) { if (string.IsNullOrEmpty(noteDto.ImagePath)) { continue; } GetPhoto mediaItem = await _photoService.GetPhoto(googleAccessToken, noteDto.ImagePath); noteDto.ImageUrl = $"{mediaItem.BaseUrl}=w2048-h1024"; } var notes = _mapper.Map <List <Note> >(noteDtos); return(notes); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { RegistrationController controller = new RegistrationController(); if (txtPasswordRepeat.Password != txtPassword.Password) { MessageBox.Show("пароли не совпадают"); return; } Client user = new Client(txtUsername.Text, txtPassword.Password, txtUserEmail.Text); user.maxCount = 1; user.role = 0; user.ChatId = 0; user.isActive = false; user.key = GetPhoto.GenRandomString(10); user.LastUpdate = DateTime.Parse("01 01 2019"); controller.Register(user); if (new LoginControl().login(user)) { EntryWindow parentWindow = Window.GetWindow(this) as EntryWindow; parentWindow.Close(); } }
/// <summary> /// Contructs the PhotoHandlerHelper. /// </summary> /// <param name="thumbnailMethod">The method to retrieve the thumbnail</param> /// <param name="fullsizeMethod">The methmod to retrieve the fullsize image</param> public PhotoHandlerHelper(GetPhoto thumbnailMethod, GetPhoto fullsizeMethod) { _thumbnailMethod = thumbnailMethod; _fullsizeMethod = fullsizeMethod; }
void timer_Tick_About(object sender, EventArgs e) { time += 500; if (time == TIME_TOOLTIP) // когда прошло нужное количество времени, запрашиваем данные о пользователе { tip.Hide(this); vk start = new vk(); GetPhoto getPhoto = new GetPhoto(start.getPhoto); IAsyncResult res1 = getPhoto.BeginInvoke(uid, "medium", null, null); while (!res1.IsCompleted) Application.DoEvents(); res1.AsyncWaitHandle.WaitOne(); photo = getPhoto.EndInvoke(res1); // photo = start.getPhoto(uid, "medium"); if (photo == null) { if (File.Exists(vars.VARS.Directory + "\\medium\\" + uid.ToString())) try { photo = Image.FromFile(vars.VARS.Directory + "\\medium\\" + uid.ToString()); } catch (OutOfMemoryException exe) { GeneralMethods.WriteError(exe.Source, exe.Message, exe.TargetSite); } else { timer.Stop(); time = 0; return; } } GetInfo getInfo = new GetInfo(start.getInfo); IAsyncResult res2 = getInfo.BeginInvoke(uid, null, null); while (!res2.IsCompleted) Application.DoEvents(); res1.AsyncWaitHandle.WaitOne(); System.Collections.Hashtable Info = getInfo.EndInvoke(res2); //System.Collections.Hashtable Info = start.getInfo(uid); if (Info != null && !Info.ContainsKey("error")) { System.Collections.ArrayList Data = (System.Collections.ArrayList)Info["response"]; name = Convert.ToString(((System.Collections.Hashtable)Data[0])["first_name"]) + " " + Convert.ToString(((System.Collections.Hashtable)Data[0])["last_name"]); string bdate = Convert.ToString(((System.Collections.Hashtable)Data[0])["bdate"]); phone = Convert.ToString(((System.Collections.Hashtable)Data[0])["mobile_phone"]); string month = ""; if (bdate != "") { string[] bday = bdate.Split('.'); switch (bday[1]) // месяц текстом чтобы был { case "1": month = "января"; break; case "2": month = "февраля"; break; case "3": month = "марта"; break; case "4": month = "апреля"; break; case "5": month = "мая"; break; case "6": month = "июня"; break; case "7": month = "июля"; break; case "8": month = "августа"; break; case "9": month = "сентября"; break; case "10": month = "октября"; break; case "11": month = "ноября"; break; case "12": month = "декабря"; break; } birthday = bday[0] + " " + month + " " + (bday.Length == 2 ? "" : bday[2]); // формируем строку дня рождения } tip.Size = new Size(220, (photo == null) ? 200 : (photo.Height + 40)); // задаём размер подсказки tip.Show(uid.ToString(), this, this.ClientRectangle.X + this.Width, this.PointToClient(Control.MousePosition).Y); // показываем подсказку } timer.Stop(); time = 0; } //throw new NotImplementedException(); }
/// <summary> /// Gets the image from the database, checks ID for integer type. /// </summary> /// <param name="photoID">string value of photoid</param> /// <param name="getPhotoMethod">Method to retreive photo</param> /// <returns>byte array of image.</returns> private static byte[] GetImage(string photoID, GetPhoto getPhotoMethod) { //declare image container byte[] image = new byte[128]; //local id variable int imageId; //test string for type of int, if it is assign it to the imageID if (int.TryParse(photoID, out imageId)) { //Retreive image with delegate method image = getPhotoMethod(imageId); } return image; }