void ReleaseDesignerOutlets() { if (ImgUser != null) { ImgUser.Dispose(); ImgUser = null; } if (LblName != null) { LblName.Dispose(); LblName = null; } if (LblFavoriteCount != null) { LblFavoriteCount.Dispose(); LblFavoriteCount = null; } if (LblRetweetCount != null) { LblRetweetCount.Dispose(); LblRetweetCount = null; } if (TxtDescription != null) { TxtDescription.Dispose(); TxtDescription = null; } }
void ReleaseDesignerOutlets() { if (ImgUser != null) { ImgUser.Dispose(); ImgUser = null; } if (LblUserLevel != null) { LblUserLevel.Dispose(); LblUserLevel = null; } if (LblUserName != null) { LblUserName.Dispose(); LblUserName = null; } if (cvSkills != null) { cvSkills.Dispose(); cvSkills = null; } }
public async void SetImage(string urlImage) { if (!string.IsNullOrWhiteSpace(urlImage)) { if (Uri.IsWellFormedUriString(urlImage, UriKind.Absolute)) { var imgBitmap = await GetImageBitmapFromUrl(urlImage); if (imgBitmap != null) { ImgUser.SetImageBitmap(imgBitmap); } else { ImgUser.SetImageResource(Resource.Drawable.ic_action_account_circle); } } else { //Display new image await Context.Resources.GetBitmapAsync(urlImage).ContinueWith((t) => { var bitmap = t.Result; if (bitmap != null) { ImgUser.SetImageBitmap(bitmap); bitmap.Dispose(); } }, TaskScheduler.FromCurrentSynchronizationContext()); } } else { // Clear the image ImgUser.SetImageBitmap(null); ImgUser.SetImageResource(Resource.Drawable.ic_action_account_circle); } }
public async Task <IActionResult> Edit(int id, FullUser fullUser, IFormFileCollection files) { int idCookie = 0; string statusPassword = ""; if (Request.Cookies.ContainsKey("IdUser") && Request.Cookies.ContainsKey("UserPassword")) { idCookie = int.Parse(Request.Cookies["IdUser"]); statusPassword = Request.Cookies["UserPassword"]; } if (statusPassword == "true" && idCookie > 0) { if (id != fullUser.OneUser.IdUser) { return(NotFound()); } if (ModelState.IsValid) { if (fullUser.BiographyUser != null) { fullUser.BiographyUser.IdUser = id; } _context.Update(fullUser.BiographyUser); if (fullUser.EducationUser != null) { fullUser.EducationUser.IdUser = id; } _context.Update(fullUser.EducationUser); if (fullUser.OneUser != null) { _context.Update(fullUser.OneUser); } if (fullUser.ServicesUser != null) { fullUser.ServicesUser.IdUser = id; } _context.Update(fullUser.ServicesUser); if (fullUser.WorkplaceUser != null) { fullUser.WorkplaceUser.IdUser = id; } _context.Update(fullUser.WorkplaceUser); await _context.SaveChangesAsync(); } else { return(View(fullUser)); } ImgUser img = new ImgUser(); foreach (var file in files) { if (file != null) { byte[] imageData = null; using (var fileStream = file.OpenReadStream()) using (var ms = new MemoryStream()) { fileStream.CopyTo(ms); imageData = ms.ToArray(); } string type = file.ContentType; img.IdUser = id; img.IdImg = 0; img.DataImg = imageData; img.TypeImg = type; _context.Add(img); } await _context.SaveChangesAsync(); int lastIdImg = _context.ImgUser.Where(p => p.IdUser == idCookie).Max(p => p.IdImg); var profile = _context.UserProfile.Find(idCookie); profile.MainImg = lastIdImg; _context.Update(profile); await _context.SaveChangesAsync(); } return(RedirectToRoute(new { controller = "UserProfiles", action = "Details", id = id })); } else { return(Redirect("/UserAuthorization/Index")); } }