Пример #1
0
 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));
 }
Пример #2
0
        public ActionResult AddTestimonials()
        {
            var model = new AddTestimonialModel();

            ViewBag.SelectedTab = SelectedAdminTab.Testimonials;
            return(View(model));
        }
Пример #3
0
        public ActionResult DisplayTestimonial(int testimonialID)
        {
            ViewBag.SelectedTab = SelectedAdminTab.Testimonials;
            var testimonialModel = new AddTestimonialModel();

            testimonialModel = _testimonialManager.GetTestimonialById(testimonialID);
            return(View(testimonialModel));
        }
Пример #4
0
        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."
                });
            }
        }