public async Task <IActionResult> Create(BlogAddDto blogAddDto, IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment) { if (ModelState.IsValid) { if (imgFile != null) { string imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\blog"); blogAddDto.ImageUrl = imgName; } else { blogAddDto.ImageUrl = "no-photo.png"; } await _blogService.InsertAsync(new Blog { AppUserId = 1, SubCategoryId = blogAddDto.SubCategoryId, ImageUrl = blogAddDto.ImageUrl, Text = blogAddDto.Text, Title = blogAddDto.Title, CreatedDate = DateTime.Now }); return(RedirectToAction("Index")); } blogAddDto.CategoryList = new SelectList(await _categoryService.GetListAsync(), "Id", "Name"); return(View(blogAddDto)); }
public async Task <IActionResult> Edit(ServiceGeneralDto serviceGeneralDto, IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment) { if (ModelState.IsValid) { if (imgFile != null) { string imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\service"); serviceGeneralDto.ImageUrl = imgName; } else { var editedService = await _serviceService.GetByIdAsync(serviceGeneralDto.Id); serviceGeneralDto.ImageUrl = editedService.ImageUrl; } await _serviceService.UpdateAsync(new Service { ImageUrl = serviceGeneralDto.ImageUrl, Id = serviceGeneralDto.Id, Text = serviceGeneralDto.Text, Title = serviceGeneralDto.Title }); return(RedirectToAction("Index")); } return(View(serviceGeneralDto)); }
public async Task <IActionResult> Create(ServiceAddDto serviceAddDto, IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment) { if (ModelState.IsValid) { if (imgFile != null) { string imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\service"); serviceAddDto.ImageUrl = imgName; } else { serviceAddDto.ImageUrl = "no-photo.png"; } await _serviceService.InsertAsync(new Service { ImageUrl = serviceAddDto.ImageUrl, Text = serviceAddDto.Text, Title = serviceAddDto.Title }); return(RedirectToAction("Index")); } return(View(serviceAddDto)); }
/// <summary> /// 上傳圖片 /// </summary> /// <returns></returns> public ActionResult ImageUpload(String strProfileID) { //ViewBag.strProductID = strProductID; ViewBag.strProfileID = strProfileID; ViewBag.SizeLimit = ImageUploadHelper.GetProfileParm("SizeLimit"); return(View()); }
public void FormViewContact_InsertItem() { var contact = _db.Contacts.Create(); TryUpdateModel(contact); // Carrega a imagem no Helper de Upload FileUpload file = (FileUpload)FormViewContact.FindControl("FileUploadPicture"); ImageUploadHelper imgUploader = new ImageUploadHelper(file); // Verifica se conseguiu carregar a imagem if (!imgUploader.IsValid) { ModelState.AddModelError("FileUploadPicture", imgUploader.ErrorMessage); return; } if (ModelState.IsValid) { contact.PictureContentType = imgUploader.ContentType; contact.PictureBytes = imgUploader.ImageBytes; _db.Contacts.Add(contact); _db.SaveChanges(); LabelMessage.Text = "Contato inserido com sucesso."; } }
/// <summary> /// Método para fazer Upload de imagens para o perfil de /// utilizador /// </summary> /// <param name="id">id do user</param> /// <param name="mainImage">Imagem</param> /// <returns>Caminho da imagem</returns> public SuccessMessageModel UploadImagesToUser(int id, IFormFile mainImage) { try { string imagesPath = ImageUploadHelper.UploadImage(mainImage, _root, id, "user"); using (SqlCommand cmd = _connection.Fetch().CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = "UPDATE dbo.[User] " + "SET ImagePath=@Ipath " + "WHERE Id=@id"; cmd.Parameters.Add("@Ipath", SqlDbType.NVarChar).Value = imagesPath; cmd.Parameters.Add("@id", SqlDbType.Int).Value = id; cmd.ExecuteNonQuery(); } return(new SuccessMessageModel("Upload sucedido!")); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <IActionResult> Create(PortofolioAddDto portofolioAddDto, IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment) { if (ModelState.IsValid) { if (imgFile != null) { var imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\portofolio"); portofolioAddDto.ImageUrl = imgName; } else { portofolioAddDto.ImageUrl = "no-image.png"; } await _portofolioService.InsertAsync(new Portofolio { SubCategoryId = portofolioAddDto.SubCategoryId, Text = portofolioAddDto.Text, Title = portofolioAddDto.Title, ImageUrl = portofolioAddDto.ImageUrl }); return(RedirectToAction("Index")); } portofolioAddDto.CategoryList = new SelectList(await _categoryService.GetListAsync(), "Id", "Name"); return(View(portofolioAddDto)); }
public async Task <ActionResult> AuthorRegister(AccountViewModel model) { if (ModelState.IsValid) { var file = Request.Files[0]; var uploadResult = ImageUploadHelper.GetUploadResult(file); var user = new ApplicationUser { UserName = model.AuthorRegister.UserName, Email = model.AuthorRegister.Email, SSNImgId = uploadResult.PublicId, Avatar = Common.Constant.DefaultAvatarLink, Cover = Common.Constant.DefaultCoverLink }; var result = await UserManager.CreateAsync(user, model.AuthorRegister.Password); if (result.Succeeded) { var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "[BookAholic]Xác Nhận Tài Khoản", "Chào mừng bạn đã đến với mạng xã hội sách BookAholic <p> Xin vui lòng click vào link để xác nhận tài khoản của bạn</p>: <a href=\"" + callbackUrl + "\">Xác Nhận tài khoản</a>"); ViewBag.Link = callbackUrl; ViewBag.Message = "Kiểm tra Email để xác nhận tài khoản của bạn, bạn phải xác nhận tài khoản trước khi Đăng Nhập"; return(View("DisplayEmail")); } AddErrors(result); } ViewBag.sliders = Context.Sliders.Find(_ => true).ToList(); ViewBag.cloudinary = cloudinary; return(View(model)); }
public async Task <IActionResult> Edit(TestimionalGeneralDto testimionalGeneralDto, IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment) { if (ModelState.IsValid) { if (imgFile != null) { string imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\testimonial"); testimionalGeneralDto.ImageUrl = imgName; } else { var editedTestimional = await _testimionalService.GetByIdAsync(testimionalGeneralDto.Id); testimionalGeneralDto.ImageUrl = editedTestimional.ImageUrl; } await _testimionalService.UpdateAsync(new Testimonial { Id = testimionalGeneralDto.Id, ImageUrl = testimionalGeneralDto.ImageUrl, IsDraft = testimionalGeneralDto.IsDraft, Name = testimionalGeneralDto.Name, Text = testimionalGeneralDto.Text, Title = testimionalGeneralDto.Title }); return(RedirectToAction("Index")); } return(View(testimionalGeneralDto)); }
public async Task <IActionResult> PhotoUpload(IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment, ProfileGeneralDto profileGeneralDto) { if (ModelState.IsValid) { var activeUser = await _appUserService.GetByIdAsync(profileGeneralDto.Id); if (imgFile != null) { string imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\profile"); profileGeneralDto.ProfileImageUrl = imgName; activeUser.ProfileImageUrl = profileGeneralDto.ProfileImageUrl; } //else //{ // profileGeneralDto.ProfileImageUrl = activeUser.ProfileImageUrl; //} //activeUser.ProfileImageUrl = profileGeneralDto.ProfileImageUrl; await _appUserService.UpdateAsync(activeUser); return(RedirectToAction("Index")); } return(null); }
public ActionResult Edit(Book book) { var listBook = Context.Books.Find(_ => true).ToList(); foreach (var eachBook in listBook) { if (eachBook.BookName.ToLower().Equals(book.BookName.ToLower()) && listBook.Find(x => x.BookName.ToLower().Equals(book.BookName.ToLower())).Id != book.Id) { ModelState.AddModelError("BookName", "Tên sách đã tồn tại"); } } if (ModelState.IsValid) { // TODO: Add update logic here //DangVH. Create. Start (02/11/2016) { var file = Request.Files[0]; var uploadResult = ImageUploadHelper.GetUploadResult(file); //DangVH. Create. End (02/11/2016) var editBook = Context.Books.Find(x => x.Id.Equals(new ObjectId(book.Id))).FirstOrDefault(); editBook.BookName = book.BookName; editBook.Authors = book.Authors; editBook.ReleaseDay = book.ReleaseDay.ToLocalTime(); editBook.Description = book.Description; if (file.ContentLength == 0) { editBook.ImgPublicId = book.ImgPublicId; } else { editBook.ImgPublicId = uploadResult.PublicId; } editBook.Categories.Clear(); //DangVH. Create. Start (14/11/2016) editBook.Publishers.Clear(); foreach (var publisherId in book.Publishers) { editBook.Publishers.Add(publisherId); } foreach (var categoryId in book.Categories) { editBook.Categories.Add(categoryId); } //DangVH. Create. End (14/11/2016) Context.Books.ReplaceOneAsync(x => x.Id.Equals(new ObjectId(book.Id)), editBook); return(RedirectToAction("Index")); } } ViewBag.bookNumber = BooksControllerHelper.GetBookNumber(); var selectedPublisherValue = book.Publishers.ToString(); var selectedCategoryValue = book.Categories.ToString(); ViewBag.publisherId = GetPubsCats(selectedPublisherValue.Split(','), 1); ViewBag.categoryId = GetPubsCats(selectedCategoryValue.Split(','), 2); ViewBag.cloudinary = cloudinary; return(View(book)); }
/// <summary> /// Método que apaga a imagem de perfil do utilizador /// </summary> /// <param name="id">Id do utilizador</param> /// <returns>Retorna True se a imagem é apagada, False caso contrário</returns> public bool deleteImage(int id) { try{ return(ImageUploadHelper.deleteUserImage(id, _root, "user")); } catch (Exception e) { throw new Exception(e.Message); } }
public ActionResult Upload(HttpPostedFileBase pubImage, string pubName, string pubAddress, string pubPhoneNo) { try { // Upload image to Cloudinary var allPublisher = Context.Publishers.Find(_ => true).ToList(); List <string> errorMessage = new List <string>(); if (pubName == "" || pubName == null) { var message = "Tên NXB không được để trống"; errorMessage.Add(message); } if (pubAddress == "" || pubAddress == null) { var message = "Địa chỉ không được để trống"; errorMessage.Add(message); } if (pubImage == null) { var message = "Ảnh NXB không được để trống"; errorMessage.Add(message); } foreach (var pub in allPublisher) { if (pub.Name.ToLower().Equals(pubName.ToLower())) { var message = "Tên NXB đã tồn tại"; errorMessage.Add(message); } } if (errorMessage.Count() == 0) { var uploadResult = ImageUploadHelper.GetUploadResult(pubImage); // Save new publisher to MongoDB Publisher publisher = new Publisher() { ImagePublicId = uploadResult.PublicId, Name = pubName, Address = pubAddress, PhoneNumber = pubPhoneNo }; Context.Publishers.InsertOneAsync(publisher); return(Json(new { success = "Thêm nhà xuất bản thành công" })); } else { return(Json(errorMessage, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json("Upload Failed. Error occurred. Error details: " + ex.Message)); } }
public ActionResult Create(Book book) { var listBook = Context.Books.Find(_ => true).ToList(); var file = Request.Files[0]; if (file.ContentLength == 0) { ModelState.AddModelError("ImgPublicId", "Ảnh sách bắt buộc"); } foreach (var eachBook in listBook) { if (book.BookName != null && eachBook.BookName.ToLower().Equals(book.BookName.ToLower())) { ModelState.AddModelError("BookName", "Tên sách đã tồn tại"); } } if (ModelState.IsValid) { var uploadResult = ImageUploadHelper.GetUploadResult(file); var addBook = new Book() { BookName = book.BookName, Authors = book.Authors, //DangVH. Delete. Start (14/11/2016) //Publishers = book.Publishers, //DangVH. Delete. End (14/11/2016) ReleaseDay = book.ReleaseDay.ToLocalTime(), Description = book.Description, ImgPublicId = uploadResult.PublicId }; foreach (var publisherId in book.Publishers) { addBook.Publishers.Add(publisherId); } foreach (var categoryId in book.Categories) { addBook.Categories.Add(categoryId); } //DangVH. Create. End (14/11/2016) Context.Books.InsertOneAsync(addBook); return(RedirectToAction("Index")); } //DangVH. Update. Start (14/11/2016) //Book newbook = BooksControllerHelper.GetCheckBoxValues(); ViewBag.bookNumber = BooksControllerHelper.GetBookNumber(); var selectedPublisherValue = book.Publishers.ToString(); var selectedCategoryValue = book.Categories.ToString(); ViewBag.publisherId = GetPubsCats(selectedPublisherValue.Split(','), 1); ViewBag.categoryId = GetPubsCats(selectedCategoryValue.Split(','), 2); //DangVH. Update. End (14/11/2016) return(View(book)); }
public IResult Delete(CarImage carImage) { var image = _carImageDal.Get(c => c.Id == carImage.Id); if (image == null) { return(new ErrorResult(Messages.ImageNotFound)); } ImageUploadHelper.Delete(image.ImagePath); _carImageDal.Delete(carImage); return(new SuccessResult(Messages.ImageDeleted)); }
/// <summary> /// Método que apaga a imagem de perfil do utilizador /// </summary> /// <param name="id">Id do utilizador</param> /// <returns>Retorna True se a imagem é apagada, False caso contrário</returns> public bool deleteImage(int id) { try { ImageUploadHelper imageUploadHelper = new ImageUploadHelper(); return(imageUploadHelper.deleteUserImage(id, "user")); } catch (Exception e) { throw new Exception(e.Message); } }
private IResult CarImageDeleteControl(CarImage carImage) { var image = _carImageDal.Get(c => c.Id == carImage.Id); if (image == null) { return(new ErrorResult(Messages.ImageNotFound)); } ImageUploadHelper.Delete(image.ImagePath); return(new SuccessResult()); }
public async Task <IActionResult> ImageEdit([FromForm] IFormFile file, [FromForm] ShopEditViewModel model) { if (file != null && file.Length > 0) { var imagePath = await ImageUploadHelper.ImageUpload(file, _env); ViewData["FileLocation"] = imagePath; model.image = imagePath; } model.statusList = GetShopStatus(); return(View("Views/Shop/ShopEditView.cshtml", model)); }
/// <summary> /// Método que retorna o nome da imagem de destaque /// </summary> /// <param name="id">Id do post</param> /// <returns>Retorna o nome da Imagem de destaque</returns> public ImageName getMainImage(int id) { if (FindById(id) == null) { throw new Exception("O Post/user não existe!"); } try { return(ImageUploadHelper.getMainImage(id, _root, "postMain")); } catch (Exception e) { throw new Exception(e.Message); } }
private byte[] GetImageBytesFromFilePath(string fileName, string rootPath) { byte[] content = null; string filePath = ImageUploadHelper.GetUploadRootPath(rootPath) + "Temp\\" + fileName; if (File.Exists(filePath)) { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { content = fs.ToBytes(); } } return(content); }
/// <summary> /// 圖片上傳頁面 /// </summary> /// /// <returns></returns> public ActionResult Upload() { // ProductMaitainModel ProductData = new ProductMaitainModel(); //if (!String.IsNullOrEmpty(strProductID)) //{ // ViewBag.PictureID = ImageUploadHelper.GetProductData(); //} //ProductData.strProductID = strProductID; //取得圖片尺寸&限制大小 ViewBag.Picture = ImageUploadHelper.GetProfileParm("Picture"); //ViewBag.BackgroundPicture = ImageUploadHelper.GetProfileParm("BackgroundPicture"); ViewBag.SizeLimit = ImageUploadHelper.GetProfileParm("SizeLimit"); return(View()); }
public IResult Add(IFormFile image, CarImage carImage) { var result = BusinessRules.Run(MaximumImageLimit(carImage.CarId), ImageExtension(image.FileName)); if (result != null) { return(result); } carImage.ImagePath = ImageUploadHelper.AddImage(image); carImage.Date = DateTime.Now; _carImageDal.Add(carImage); return(new SuccessResult("Yeni Resim Eklendi")); }
public IResult Add(IFormFile image, CarImage carImage) { var imageCount = _carImageDal.GetAll(c => c.CarId == carImage.CarId).Count; if (imageCount >= 5) { //5 den fazla fotoğraf olmasın diye yazdığımız kural return(new ErrorResult(Messages.ImageLimitExceded)); } var imageResult = ImageUploadHelper.Upload(image); carImage.ImagePath = imageResult.Message; //Upload dan gelen mesaj bir dosya yoludur. _carImageDal.Add(carImage); return(new SuccessResult(Messages.ImageAded)); }
public IResult Update(IFormFile image, CarImage carImage) { var theImage = _carImageDal.Get(c => c.Id == carImage.Id); if (theImage == null) { return(new ErrorResult("Image Not Found")); //Seçilen bir resim yoksa bunu ver. } var updatedFile = ImageUploadHelper.Update(image, theImage.ImagePath); theImage.ImagePath = updatedFile.Message; theImage.Date = DateTime.Now; _carImageDal.Update(theImage); return(new SuccessResult(Messages.ImageUpdated)); }
/// <summary> /// Método que retorna uma lista com os nomes das imagens /// do jobPost /// </summary> /// <param name="id">Id do post</param> /// <returns>Retorna lista com nomes de imagens</returns> public List <ImageName> getImages(int id) { if (FindById(id) == null) { throw new Exception("O Post não existe!"); } try { return(ImageUploadHelper.getImages(id, _root, "post")); } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// Método para fazer Upload de imagens para o perfil de /// utilizador /// </summary> /// <param name="id">id do user</param> /// <param name="mainImage">Imagem</param> /// <returns>Caminho da imagem</returns> public bool UploadImagesToUser(int id, IFormFile mainImage) { bool result = true; try { ImageUploadHelper imageUploadHelper = new ImageUploadHelper(); string imagesPath = imageUploadHelper.UploadImage(mainImage, id, "user"); return(result); } catch (Exception e) { throw new Exception(e.Message); } }
private async Task UploadPhoto(bool isSupported, Func <Task <MediaFile> > taskFactory) { try { await CrossMedia.Current.Initialize(); if (isSupported == false) { await DisplayAlert("Not supported", "Your device does not support this functionality", "Ok"); return; } var task = taskFactory(); var file = await task; if (file == null) { return; } SetBusy(); var watch = new Stopwatch(); watch.Start(); var stream = file.GetStream(); var uri = await ImageUploadHelper.UploadFileAsync(stream); watch.Stop(); await Xamarin.Essentials.Browser.OpenAsync(uri.AbsoluteUri); await DisplayAlert($"File uploaded! ({watch.ElapsedMilliseconds:n0} ms)", uri.ToString(), "OK"); } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "OK"); } finally { SetNotBusy(); } }
/// <summary> /// Método que retorna o nome da imagem de perfil /// do user /// </summary> /// <param name="id">Id do user</param> /// <returns>Nome da Imagem de perfil</returns> public ImageName getProfileImage(int id) { if (FindById(id) == null) { throw new Exception("O user não existe!"); } try { ImageUploadHelper imageUploadHelper = new ImageUploadHelper(); return(imageUploadHelper.getMainImage(id, "user")); } catch (Exception e) { throw new Exception(e.Message); } }
public ActionResult Upload(string desc) { try { //Configuration //DangVH. Delete. Start (02/11/2016) //Account account = new Account("dsddvwiqz", "677568653855233", "_RCoQNjMqr8Nt7-FAgs5T_guiWM"); //var cloudinary = new Cloudinary(account); //var cloudinary = ImageUploadHelper.GetCloudinaryAccount(); //DangVH. Delete. End (02/11/2016) var file = Request.Files[0]; if (file == null) { return(Json(new { result = false })); } //Upload Image //DangVH. Update. Start (01/11/2016) //var uploadParam = new ImageUploadParams() //{ // File = new FileDescription(file.FileName, file.InputStream), //}; //var uploadResult = cloudinary.Upload(uploadParam); var uploadResult = ImageUploadHelper.GetUploadResult(file); //DangVH. Update. End (01/11/2016) //Save photo (publicID) to MongoDB Slider mongoPhoto = new Slider() { PublicId = uploadResult.PublicId, Desc = desc, // HuyenPT. Create. Start. 06-12-2016 isShow = true, // HuyenPT. Create. End. 06-12-2016 }; Context.Sliders.InsertOneAsync(mongoPhoto); return(Json("Đã thêm mới slide thành công!")); } catch { return(Json("Đã xảy ra lỗi")); } }
public IResult Update(IFormFile image, CarImage carImage) { var oldImagePath = _carImageDal.Get(i => i.Id == carImage.Id).ImagePath; var result = BusinessRules.Run(MaximumImageLimit(carImage.CarId), ImageExtension(image.FileName)); if (result != null) { return(result); } carImage.ImagePath = ImageUploadHelper.UpdateImage(image, oldImagePath); carImage.Date = DateTime.Now; _carImageDal.Update(carImage); return(new SuccessResult("Resim güncellendi.")); }
private bool CheckIfImageFile(IFormFile file) { byte[] fileBytes; using (var ms = new MemoryStream()) { file.CopyTo(ms); fileBytes = ms.ToArray(); } var type = ImageUploadHelper.GetImageFormat(fileBytes); if (type != ImageUploadHelper.ImageFormat.jpeg && type != ImageUploadHelper.ImageFormat.png) { return(false); } return(true); }
public void Submit_Click(object sender, EventArgs e) { try { if(uploadPhoto.HasFile) { var photobytes = uploadPhoto.FileBytes; var helper = new ImageUploadHelper(); helper.UploadImage(photobytes, string.Empty, true); ExigoApiContext.CreateWebServiceContext().SetCustomerSiteImage(new SetCustomerSiteImageRequest { CustomerID = Identity.Current.CustomerID, CustomerSiteImageType = CustomerSiteImageType.Primary, ImageName = "avatar", ImageData = GlobalUtilities.ResizeImage(photobytes, GlobalSettings.CustomerImages.MaxImageWidth, GlobalSettings.CustomerImages.MaxImageHeight) }); } // Save the customer site information ExigoApiContext.CreateWebServiceContext().SetCustomerSite(new SetCustomerSiteRequest { CustomerID = Identity.Current.CustomerID, WebAlias = Identity.Current.Website.WebAlias, FirstName = FirstName, LastName = LastName, Company = Company, Address1 = Address, City = City, State = State, Zip = Zip, Country = Country, Phone = Phone, Phone2 = Phone2, Email = Email, Notes1 = Notes }); // Save the social network information var socialrequest = new SetCustomerSocialNetworksRequest(); socialrequest.CustomerID = Identity.Current.CustomerID; var urls = new List<CustomerSocialNetworkRequest>(); if(!string.IsNullOrEmpty(Facebook)) urls.Add(new CustomerSocialNetworkRequest() { SocialNetworkID = (int)SocialNetworks.Facebook, Url = Facebook }); if(!string.IsNullOrEmpty(Twitter)) urls.Add(new CustomerSocialNetworkRequest() { SocialNetworkID = (int)SocialNetworks.Twitter, Url = Twitter }); if(!string.IsNullOrEmpty(LinkedIn)) urls.Add(new CustomerSocialNetworkRequest() { SocialNetworkID = (int)SocialNetworks.LinkedIn, Url = LinkedIn }); if(!string.IsNullOrEmpty(YouTube)) urls.Add(new CustomerSocialNetworkRequest() { SocialNetworkID = (int)SocialNetworks.YouTube, Url = YouTube }); if(!string.IsNullOrEmpty(Pinterest)) urls.Add(new CustomerSocialNetworkRequest() { SocialNetworkID = (int)SocialNetworks.Pinterest, Url = Pinterest }); socialrequest.CustomerSocialNetworks = urls.ToArray(); if(socialrequest.CustomerSocialNetworks.Length > 0) { ExigoApiContext.CreateWebServiceContext().SetCustomerSocialNetworks(socialrequest); } Response.Redirect(Request.Url.AbsolutePath + "?status=1"); } catch(Exception ex) { Error.Type = ErrorMessageType.Failure; Error.Header = "Oops!"; Error.Message = "We were unable to save your changes: " + ex.Message; } }