public JsonResult UpdatetestimonialDetails(AddTestimonialModel model) { model.userType = UserTypes.Admin; model.UserFK = LOGGEDIN_USER.UserID; ViewBag.SelectedTab = SelectedAdminTab.Testimonials; return(Json(_testimonialManager.AddUpdateTestimonial(model), JsonRequestBehavior.AllowGet)); }
public ActionResult AddTestimonials() { var model = new AddTestimonialModel(); ViewBag.SelectedTab = SelectedAdminTab.Testimonials; return(View(model)); }
public ActionResult DisplayTestimonial(int testimonialID) { ViewBag.SelectedTab = SelectedAdminTab.Testimonials; var testimonialModel = new AddTestimonialModel(); testimonialModel = _testimonialManager.GetTestimonialById(testimonialID); return(View(testimonialModel)); }
ActionOutput ITestimonialManager.AddUpdateTestimonial(AddTestimonialModel testimonialModel) { try { if (testimonialModel.ID > 0) { var testimonial = Context.tblTestimonials.Where(z => z.ID == testimonialModel.ID && z.IsDeleted != true).FirstOrDefault(); if (testimonial != null) { testimonial.Title = testimonialModel.Title; if (testimonialModel.Image == null) { testimonial.Image = testimonialModel.ImageName; } else { testimonial.Image = Utilities.SaveImage(testimonialModel.Image, AppDefaults.TestimonialsPath, AppDefaults.TestimonialsThumbPath); } testimonial.Name = testimonialModel.Name; testimonial.Description = testimonialModel.Description; Context.SaveChanges(); return(new ActionOutput { Status = ActionStatus.Successfull, Message = "Sucessfully Updated." }); } else { return(new ActionOutput { Status = ActionStatus.Error, Message = "No testimonial found." }); } } else { var newTestimonial = new tblTestimonial(); newTestimonial.Title = testimonialModel.Title; newTestimonial.Name = testimonialModel.Name; newTestimonial.Description = testimonialModel.Description; newTestimonial.IsActive = testimonialModel.IsActive; newTestimonial.ActivatedOn = DateTime.UtcNow; newTestimonial.AddedOn = DateTime.UtcNow; newTestimonial.Image = Utilities.SaveImage(testimonialModel.Image, AppDefaults.TestimonialsPath, AppDefaults.TestimonialsThumbPath); newTestimonial.IsDeleted = testimonialModel.IsDeleted; newTestimonial.DeletedOn = testimonialModel.DeletedOn; Context.tblTestimonials.Add(newTestimonial); Context.SaveChanges(); return(new ActionOutput { Status = ActionStatus.Successfull, Message = "Sucessfully Added." }); } } catch (Exception ex) { return(new ActionOutput { Status = ActionStatus.Error, Message = "Internal Server error." }); } }