public void AddPic(Picture picture) { var pic = new PictureVM { Id = picture.Id, MSource = PictureExtensions.ImagePath(picture.Id + picture.Extension, "m", picture.Created), SSource = PictureExtensions.ImagePath(picture.Id + picture.Extension, "s", picture.Created), }; Pics.Add(pic); }
public string Picture(string photo) { var src = PictureExtensions.NoPhoto; if (string.IsNullOrEmpty(photo)) { return(src); } src = PictureExtensions.ImagePath($"{photo}", "i", DateTime.Now); return(src); }
public void SavePicture(string Id) { if (!string.IsNullOrEmpty(Id)) { var pic = new PictureVM { Id = Guid.Parse(Id), MSource = PictureExtensions.ImagePath(Id + ".jpg", "m", DateTime.Now), SSource = PictureExtensions.ImagePath(Id + ".jpg", "s", DateTime.Now), }; Pics.Add(pic); } }
public string Picture(Picture picture) { var src = PictureExtensions.NoImage; if (picture == null) { return(src); } if (!string.IsNullOrEmpty(picture.Id.ToString())) { src = PictureExtensions.ImagePath(picture.Id + picture.Extension, "m", picture.Created); } return(src); }
public static string Compress(IFormFile picture, string type, int desiredWidth, string fileName) { string fullPath; fullPath = PictureExtensions.CreatePath(type, fileName); using (var image = Image.Load(picture.OpenReadStream())) { float ratio = Ratio(image, desiredWidth); image.Mutate(x => x.Resize(PictureExtensions.RoundOff((int)(image.Width * ratio), 10), PictureExtensions.RoundOff((int)(image.Height * ratio), 10))); image.Save(fullPath); } return(PictureExtensions.ImagePath(fileName, type, DateTime.Now)); }
void CurrentUserInfoChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(CurrentUserInfo.CurrentUser.FullName)) { Profile.FullName = "No name"; } else { Profile.FullName = CurrentUserInfo.CurrentUser.FullName; } if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUser.Photo)) { Profile.Pic = PictureExtensions.ImagePath($"{CurrentUserInfo.CurrentUser.Photo}", "i", DateTime.Now); } StateHasChanged(); }
protected override async Task OnInitializedAsync() { ProfilePic = "images/no-photo.jpg"; User = await CustomerService.GetUserAsync(CurrentUserInfo.CurrentUser.Id); Mapper.Map <AppUser, UserEditViewModel>(User, Profile); Selections = await CustomerService.GetUserRolesAsync(CurrentUserInfo.CurrentUser.Id); Profile.Roles = Selections.ToArray(); if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUser.Photo)) { ProfilePic = PictureExtensions.ImagePath($"{CurrentUserInfo.CurrentUser.Photo}", "i", DateTime.Now); } ProfileContext = new EditContext(Profile); ProfileContext.OnFieldChanged += HandleFieldChanged; }
//protected override async Task OnInitializedAsync() //{ //} protected override async Task OnParametersSetAsync() { Id = Id ?? "1"; Article = await ArticleService.GetAsync(int.Parse(Id)); foreach (var picture in Article.Pictures) { var pic = new PictureVM { Id = picture.Id, MSource = PictureExtensions.ImagePath(picture.Id + picture.Extension, "m", picture.Created), NSource = PictureExtensions.ImagePath(picture.Id + picture.Extension, "n", picture.Created), Active = "" }; Pics.Add(pic); } if (Pics.Count > 0) { Pics.First().Active = "active"; } }