public ActionResult RenderTestimonials() { IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string title = homePage.GetPropertyValue <string>("testimonialsTitle"); string introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); List <Testimonial> testimonials = new List <Testimonial>(); // get the testimonialList from Umbraco, type archetype ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList"); if (testimonialList != null) { foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS)) { string name = testimonial.GetValue <string>("name"); string quote = testimonial.GetValue <string>("quote"); testimonials.Add(new Testimonial(quote, name)); } } Testimonials model = new Testimonials(title, introduction, testimonials); return(PartialView("~/Views/Partials/Home/_Testimonials.cshtml", model)); }
public async Task <IActionResult> DeletePost(int?id) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } Testimonials category = await _context.Testimonials.FindAsync(id); string computerPhoto = Path.Combine(_env.WebRootPath, "images", category.PhotoURL); if (System.IO.File.Exists(computerPhoto)) { System.IO.File.Delete(computerPhoto); } _context.Testimonials.Remove(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(Testimonials Test, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { string fileName = DateTime.Now.ToString("yyyyMMddHHssmmffff") + file.FileName; file.SaveAs(Server.MapPath("~/Content/SiteImages/") + fileName); Test.Photo = fileName; db.Entry(Test).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { db.Entry(Test).State = System.Data.Entity.EntityState.Modified; db.Entry(Test).Property(p => p.Photo).IsModified = false; db.SaveChanges(); } return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }
public ActionResult RenderTestimonials() { IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string title = homePage.GetPropertyValue <string>("testimonialsTitle"); string introduction = homePage.GetPropertyValue("testimonialsIntro").ToString(); List <Testimonial> testimonials = new List <Testimonial>(); ArchetypeModel testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialsList"); if (testimonialsList != null) { foreach (ArchetypeFieldsetModel testimonial in testimonialsList.Take(2)) { string name = testimonial.GetValue <string>("name"); string quote = testimonial.GetValue <string>("quote"); testimonials.Add(new Testimonial(name, quote)); } } Testimonials model = new Testimonials(title, introduction, testimonials); return(PartialView(PartialViewPath("_Testimonials"), model)); }
public ActionResult RenderTestimonials() { var homePage = Umbraco.TypedContentAtRoot().First(); var quotes = new List <TestimonialQuote>(); var testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList"); foreach (var quote in testimonialsList) { quotes.Add(new TestimonialQuote { Name = quote.GetValue <string>("name"), Quote = quote.GetValue <string>("quote") }); } var model = new Testimonials { Title = homePage.GetPropertyValue <string>("testimonialsTitle"), Introduction = homePage.GetPropertyValue <string>("testimonialsIntroduction"), Quotes = quotes }; return(PartialView(PartialViewFolder + "_Testimonials.cshtml", model)); }
public IActionResult Edit(int?id) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (id == null) { return(View("Error")); } Testimonials category = _context.Testimonials.Find(id); var viewModel = new CreateTestimonialsVM { FullNameAZ = category.TestimonialLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "az").FullName, FullNameEN = category.TestimonialLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "en").FullName, FullNameRU = category.TestimonialLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "ru").FullName, DescriptionAZ = category.TestimonialLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "az").Description, DescriptionEN = category.TestimonialLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "en").Description, DescriptionRU = category.TestimonialLangs.FirstOrDefault(x => x.Lang.Code.ToLower() == "ru").Description, }; return(View(viewModel)); }
public ActionResult RenderTestimonials() { // render blog, get the home page IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); // gets these two properties on the home page string title = homePage.GetPropertyValue <string>("testimonialsTitle"); // comes as HTML string introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); // get testimonials from Umbraco List <Testimonial> testimonials = new List <Testimonial>(); //populate the list we need to get the value ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList"); if (testimonialList != null) { foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS)) { string name = testimonial.GetValue <string>("name"); string quote = testimonial.GetValue <string>("quote"); testimonials.Add(new Testimonial(quote, name)); } } // pass testimonials to Testimonials model //it has created the model Testimonials model = new Testimonials(title, introduction, testimonials); return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model)); }
public ActionResult Edit(Testimonials testimonials) { if (ModelState.IsValid) { Testimonials testimonials1 = context.Testimonials.Find(testimonials.Id); if (testimonials.ImgFile != null) { string imgName = DateTime.Now.ToString("ddMMyyyyHHmmssfff") + testimonials.ImgFile.FileName; string imgPath = Path.Combine(Server.MapPath("~/Uploads/"), imgName); string oldPath = Path.Combine(Server.MapPath("~/Uploads"), testimonials1.Image); System.IO.File.Delete(oldPath); testimonials.ImgFile.SaveAs(imgPath); testimonials1.Image = imgName; } testimonials1.Person = testimonials.Person; testimonials1.Position = testimonials.Position; testimonials1.Text = testimonials.Text; context.Entry(testimonials1).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public async Task <IActionResult> Edit(int id, [Bind("Company,ShortDesc,Id")] Testimonials testimonials) { if (id != testimonials.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(testimonials); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TestimonialsExists(testimonials.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(testimonials)); }
public Testimonials AddOrUpdate(Testimonials entity) { try { _db.Entry(entity).State = entity.ID == 0 ? EntityState.Added : EntityState.Modified; _db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(entity); }
public ActionResult DeleteConfirmed(int id) { Testimonials testimonials = db.Testimonials.Find(id); db.Testimonials.Remove(testimonials); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { Testimonials testimonials = await db.Testimonials.FindAsync(id); db.Testimonials.Remove(testimonials); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IActionResult> EditPost(int id, CreateTestimonialsVM category) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } if (!User.IsInRole("Admin")) { return(RedirectToAction("Login", "Account")); } if (!ModelState.IsValid) { ModelState.AddModelError("", "Xaiş olunur düzgün doldurun."); return(View(category)); } Testimonials newCategory = await _context.Testimonials.FindAsync(id); if (newCategory == null) { return(View("Error")); } if (category.Photo != null) { string computerPhoto = Path.Combine(_env.WebRootPath, "images", newCategory.PhotoURL); if (System.IO.File.Exists(computerPhoto)) { System.IO.File.Delete(computerPhoto); } string fileName = await category.Photo.SaveAsync(_env.WebRootPath); newCategory.PhotoURL = fileName; } TestimonialsLang azBlogLangFromDb = await _context.TestimonialsLangs.FirstOrDefaultAsync(x => x.Lang.Code.ToLower() == "az" && x.TestimonialsId == newCategory.Id); TestimonialsLang ruBlogLangFromDb = await _context.TestimonialsLangs.FirstOrDefaultAsync(x => x.Lang.Code.ToLower() == "ru" && x.TestimonialsId == newCategory.Id); TestimonialsLang enBlogLangFromDb = await _context.TestimonialsLangs.FirstOrDefaultAsync(x => x.Lang.Code.ToLower() == "en" && x.TestimonialsId == newCategory.Id); azBlogLangFromDb.FullName = category.FullNameAZ; enBlogLangFromDb.FullName = category.FullNameEN; ruBlogLangFromDb.FullName = category.FullNameRU; azBlogLangFromDb.Description = category.DescriptionAZ; enBlogLangFromDb.Description = category.DescriptionEN; ruBlogLangFromDb.Description = category.DescriptionRU; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(int Id) { Testimonials testimonials = context.Testimonials.Find(Id); if (testimonials == null) { return(HttpNotFound()); } return(View(testimonials)); }
public ActionResult Edit([Bind(Include = "Id,Text,PersonName")] Testimonials testimonials) { if (ModelState.IsValid) { db.Entry(testimonials).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public async Task <IActionResult> Create([Bind("Id,Testimony,UserId,isApproved,UploadedFile,ImageName")] Testimonials testimonials) { if (!User.IsInRole("Admin")) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); testimonials.UserId = userId; testimonials.isApproved = false; testimonials.ImageName = "not available"; } try { try { var iscorrectformat = false; string uniqueName = null; string filePath = null; FileInfo fi = new FileInfo(testimonials.UploadedFile.FileName); var actualextension = fi.Extension; var imageextensions = FileFormat.GetSupportedImageTypeExtensionsList(); foreach (var imageExtension in imageextensions) { if (imageExtension == actualextension) { iscorrectformat = true; } } if (iscorrectformat == false) { return(View(testimonials)); } if (testimonials.UploadedFile != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "Images"); uniqueName = Guid.NewGuid().ToString() + "_" + testimonials.UploadedFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueName); testimonials.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create)); testimonials.ImageName = uniqueName; } } catch { return(View(testimonials)); } _context.Add(testimonials); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { } ViewData["UserId"] = new SelectList(_context.Users, "Id", "UserName", testimonials.UserId); return(View(testimonials)); }
public async Task <IActionResult> Create([Bind("Company,ShortDesc,Id")] Testimonials testimonials) { if (ModelState.IsValid) { _context.Add(testimonials); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(testimonials)); }
public async Task <ActionResult> Edit([Bind(Include = "id,Content,FullName,Image")] Testimonials testimonials) { if (ModelState.IsValid) { db.Entry(testimonials).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public ActionResult Create([Bind(Include = "Id,Text,PersonName")] Testimonials testimonials) { if (ModelState.IsValid) { db.Testimonials.Add(testimonials); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public async Task <ActionResult> Create([Bind(Include = "id,Content,FullName,Image")] Testimonials testimonials) { if (ModelState.IsValid) { db.Testimonials.Add(testimonials); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public ResultModel <bool> CreateTestimonials(TestimonialsModel testimonialsModel) { ResultModel <bool> result = new ResultModel <bool>(); Testimonials testimonials = new Testimonials(testimonialsModel.Name, testimonialsModel.Description, testimonialsModel.ProjectName, testimonialsModel.URL, testimonialsModel.Designation); testimonials.CreatedBy = 1; unitOfWork.TestimonialsRepository.Insert(testimonials); result.StatusCode = Convert.ToInt32(Enums.StatusCode.OK); result.Data = true; result.Success = true; return(result); }
private Testimonials TestimonialMap(IDataReader reader) { Testimonials t = new Testimonials(); int startingIndex = 0; t.Id = reader.GetSafeInt32(startingIndex++); t.Title = reader.GetSafeString(startingIndex++); t.Body = reader.GetSafeString(startingIndex++); t.StarRating = reader.GetSafeInt32(startingIndex++); return(t); }
public async Task <ActionResult> Create([Bind(Include = "Tid,Message,Name,Designation,Image")] Testimonials testimonials, HttpPostedFileBase file, Helper help) { if (ModelState.IsValid) { testimonials.Image = help.uploadfile(file); db.Testimonials.Add(testimonials); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public async Task <ActionResult> Edit([Bind(Include = "Tid,Message,Name,Designation,Image")] Testimonials testimonials, HttpPostedFileBase file, Helper help) { if (ModelState.IsValid) { testimonials.Image = file != null?help.uploadfile(file) : img; db.Entry(testimonials).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(testimonials)); }
public ActionResult Delete(int Id) { Testimonials testimonials = context.Testimonials.Find(Id); if (testimonials == null) { return(HttpNotFound()); } context.Testimonials.Remove(testimonials); context.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Auth/Testimonials/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Testimonials testimonials = await db.Testimonials.FindAsync(id); if (testimonials == null) { return(HttpNotFound()); } return(View(testimonials)); }
public async Task <IActionResult> Update(int?id) { if (id == null) { return(NotFound()); } Testimonials testimonials = await _db.Testimonials.FindAsync(id); if (testimonials == null) { return(NotFound()); } return(View(testimonials)); }
// GET: Admin/Testimonials/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Testimonials testimonials = db.Testimonials.Find(id); if (testimonials == null) { return(HttpNotFound()); } return(View(testimonials)); }
/// <summary> /// Adds the testimonial. /// </summary> /// <param name="testimonials">The testimonials.</param> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> public long AddTestimonial(Testimonials testimonials) { try { context.Testimonials.Add(testimonials); context.SaveChanges(); return(testimonials.TestimonialId); } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + " ::::: " + ex.StackTrace); throw ex; } }
public Testimonials Get(int id) { Testimonials t = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Testimonial_SelectById", inputParamMapper : delegate(SqlParameterCollection parameterCollection) { parameterCollection.AddWithValue("@Id", id); }, map : delegate(IDataReader reader, short set) { t = TestimonialMap(reader); } ); return(t); }