public ActionResult Add()
        {
            ViewBag.SchoolID = _sModel.SchoolID;
            TestimonialManageModel model = new TestimonialManageModel();

            model.Components = objcomp.GetComponentList("");
            model.SchoolList = ObjSch.GetSchoolList("");
            return(View(model));
        }
        public ActionResult Edit(long id)
        {
            ViewBag.SchoolID = _sModel.SchoolID;
            TestimonialManageModel model = new TestimonialManageModel();

            model.Components  = objcomp.GetComponentList("");
            model.SchoolList  = ObjSch.GetSchoolList("");
            model.Testimonial = objTesti.GetTestimonialByID(id);
            return(View(model));
        }
        /// <summary>
        /// Update Testimonial data
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel UpdateTestimonialData(XEditableModel model)
        {
            var testimonial = GetById(model.Pk);

            if (testimonial != null)
            {
                var property =
                    ReflectionUtilities.GetAllPropertiesOfType(typeof(TestimonialManageModel))
                    .FirstOrDefault(p => p.Name.Equals(model.Name, StringComparison.CurrentCultureIgnoreCase));
                if (property != null)
                {
                    object value = model.Value.ToType(property, WorkContext.CurrentTimezone);

                    #region Validate

                    var manageModel = new TestimonialManageModel(testimonial);
                    manageModel.SetProperty(model.Name, value);

                    var validationResults = manageModel.ValidateModel();

                    if (validationResults.Any())
                    {
                        return(new ResponseModel
                        {
                            Success = false,
                            Message = validationResults.BuildValidationMessages()
                        });
                    }

                    #endregion

                    testimonial.SetProperty(model.Name, value);

                    var response = Update(testimonial);
                    return(response.SetMessage(response.Success
                        ? T("Testimonial_Message_UpdateTestimonialInfoSuccessfully")
                        : T("Testimonial_Message_UpdateTestimonialInfoFailure")));
                }
                return(new ResponseModel
                {
                    Success = false,
                    Message = T("Testimonial_Message_PropertyNotFound")
                });
            }
            return(new ResponseModel
            {
                Success = false,
                Message = T("Testimonial_Message_ObjectNotFound")
            });
        }
Beispiel #4
0
        // GET: Testimonials
        public ActionResult Index(long SCID = 0, int PageNo = 1, int PageSize = 3, string searchTerm = "")
        {
            TestimonialManageModel  model   = new TestimonialManageModel();
            TestimonialGenViewModel _tmodel = new TestimonialGenViewModel();

            _tmodel = ObjTestimonial.GenTestimonialSelectPaged(SCID, PageNo, PageSize, searchTerm);
            model.GenTestimonials       = _tmodel;
            model.Components            = ObjComp.GetComponentList("");
            model.GenComponentModelList = ObjComp.GetGenComponentList();//Component List
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_pvTetimonialList", model));
            }
            return(View(model));
        }
        // GET: Admin/Testimonial
        public ActionResult Index(int PageNo = 1, int PageSize = 10, string searchTerm = "")
        {
            int TotalRecords             = 0;
            TestimonialManageModel model = new TestimonialManageModel();

            model.TestimonialView = objTesti.GetTestimonialPaged(PageNo, PageSize, _sModel.SchoolID, searchTerm, out TotalRecords);
            model.PagingInfo      = new PagingInfo {
                CurrentPage = PageNo, ItemsPerPage = PageSize, TotalItems = TotalRecords
            };
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_pvTetimonialList", model));
            }
            return(View(model));
        }
        public ActionResult Add(TestimonialManageModel model)
        {
            ViewBag.SchoolID = _sModel.SchoolID;
            if (model.Testimonial.SchoolID == 0)
            {
                model.Testimonial.SchoolID = _sModel.SchoolID;
            }
            var validData = true;

            if (model.PhotoStrs.PhotoNormal == null)
            {
                ModelState.AddModelError("PhotoStrs.PhotoNormal", "Select a Photo");
                validData = false;
            }
            if (ModelState.IsValid && validData)
            {
                Random rand          = new Random();
                string name          = "T_Image_" + DateTime.Now.ToString("yyyyMMdd") + "_" + rand.Next(50) + ".jpg";
                string normal_result = SaveImage(model.PhotoStrs.PhotoNormal, name);
                if (normal_result.Contains("Error"))
                {
                    TempData["ErrMsg"] = normal_result;
                    return(View(model));
                }
                model.Testimonial.ImagePath   = FileUrl + "TestimonialImage/" + normal_result;
                model.Testimonial.IsPublished = false;
                model.Testimonial.TransDate   = DateTime.Now;
                model.Testimonial.UserID      = User.Identity.Name;
                string result = objTesti.SaveTestimonial(model.Testimonial);
                if (result.Contains("Success"))
                {
                    objSite.AddAuditLog("utblTestimonials", "New Tetimonial Added", IPAddressGetter.GetIPAddress(), User.Identity.Name);

                    TempData["ErrMsg"] = result;
                    return(RedirectToAction("index", "testimonial", new { Area = "Admin" }));
                }
                TempData["ErrMsg"] = result;
                return(RedirectToAction("index", "testimonial", new { Area = "Admin" }));
            }
            model.Components = objcomp.GetComponentList("");
            model.SchoolList = ObjSch.GetSchoolList("");
            return(View(model));
        }
        public ActionResult Create(TestimonialManageModel model, SubmitType submit)
        {
            if (ModelState.IsValid)
            {
                var response = _testimonialService.SaveTestimonial(model);
                SetResponseMessage(response);
                if (response.Success)
                {
                    switch (submit)
                    {
                    case SubmitType.Save:
                        return(RedirectToAction("Index"));

                    default:
                        return(RedirectToAction("Edit", new { id = (int)response.Data }));
                    }
                }
            }
            return(View(model));
        }
        public ActionResult Edit(TestimonialManageModel model, string returnUrl, SubmitType submit)
        {
            if (ModelState.IsValid)
            {
                var response = _testimonialService.SaveTestimonial(model);
                SetResponseMessage(response);
                if (response.Success)
                {
                    switch (submit)
                    {
                    case SubmitType.Save:
                        if (!string.IsNullOrEmpty(returnUrl))
                        {
                            return(Redirect(returnUrl));
                        }
                        return(RedirectToAction("Index"));

                    default:
                        return(RedirectToAction("Edit", new { id = model.Id, returnUrl }));
                    }
                }
            }
            return(View(model));
        }
        /// <summary>
        /// Save Testimonial
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveTestimonial(TestimonialManageModel model)
        {
            ResponseModel response;
            var           testimonial = GetById(model.Id);

            if (testimonial != null)
            {
                testimonial.Author            = model.Author;
                testimonial.Content           = model.Content;
                testimonial.AuthorDescription = model.AuthorDescription;
                testimonial.AuthorImageUrl    = model.AuthorImageUrl;

                response = Update(testimonial);
                return(response.SetMessage(response.Success
                    ? T("Testimonial_Message_UpdateSuccessfully")
                    : T("Testimonial_Message_UpdateFailure")));
            }
            Mapper.CreateMap <TestimonialManageModel, Testimonial>();
            testimonial = Mapper.Map <TestimonialManageModel, Testimonial>(model);
            response    = Insert(testimonial);
            return(response.SetMessage(response.Success
                ? T("Testimonial_Message_CreateSuccessfully")
                : T("Testimonial_Message_CreateFailure")));
        }