public async Task <IActionResult> Index(int page = 1)
        {
            double totalCount = await _context.Testimonials.CountAsync();

            int pageCount = (int)Math.Ceiling(totalCount / 5);

            if (page < 1)
            {
                page = 1;
            }
            else if (page > pageCount)
            {
                page = pageCount;
            }

            ViewBag.PageCount    = pageCount;
            ViewBag.SelectedPage = page;

            TestimonialViewModel testmonialVm = new TestimonialViewModel
            {
                Testimonials = _context.Testimonials.Skip((page - 1) * 5).Take(5).ToList()
            };

            return(View(testmonialVm));
        }
Пример #2
0
        public void Create(TestimonialViewModel command)
        {
            var newtestimonial = new Testimonial(command.StudentName, command.StudentImg, command.StudentEmail, command.CourseName, command.UniversityName, command.EduYear, command.Title, command.Description);

            _irepository.Create(newtestimonial);
            _irepository.SaveChanges();
        }
Пример #3
0
        public ActionResult Create(TestimonialViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = Mapper.Map <TestimonialViewModel, Testimonial>(viewModel);

                    _testimonialService.Insert(entity);

                    viewModel.Locales.ToList().ForEach(l =>
                    {
                        _localizedEntityService.SaveLocalizedValue(entity, e => e.Text, l.Text, l.LanguageId);
                    });

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }

            //viewModel.ClientsSelectList = Mapper.Map<List<Client>, List<SelectListItem>>(_clientService.GetAll());
            viewModel.ProjectsSelectList = Mapper.Map <List <Project>, List <SelectListItem> >(_projectService.GetAll());

            return(View(viewModel));
        }
        public JsonResult Get_Testimonials(TestimonialViewModel tViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            try
            {
                pager = tViewModel.Pager;

                tViewModel.testimonials = _testimonialMan.Get_Testimonials(ref pager);

                tViewModel.Pager = pager;

                tViewModel.Pager.PageHtmlString = PageHelper.NumericPager("javascript:PageMore({0})", tViewModel.Pager.TotalRecords, tViewModel.Pager.CurrentPage + 1, tViewModel.Pager.PageSize, 10, true);
            }
            catch (Exception ex)
            {
                tViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Testimonial Controller - Get_Testimonials: " + ex.ToString());
            }
            finally
            {
                pager = null;
            }

            return(Json(tViewModel));
        }
Пример #5
0
 public bool Put([FromBody] TestimonialViewModel testimonial)
 {
     if (testimonial != null)
     {
         Mapper.Initialize(cfg => cfg.CreateMap <TestimonialViewModel, TestimonialEntity>());
         var testimonialEntity = Mapper.Map <TestimonialViewModel, TestimonialEntity>(testimonial);
         return(testimonialServices.UpdateTestimonial(testimonialEntity));
     }
     return(false);
 }
Пример #6
0
        public ActionResult Manage()
        {
            DatabaseService service = new DatabaseService();

            TestimonialViewModel model = new TestimonialViewModel();

            model.Testimonials = service.GetTestimonials();

            return(View(model));
        }
Пример #7
0
 // POST: api/Testimonials
 public int Post([FromBody] TestimonialViewModel testimonial)
 {
     if (testimonial != null)
     {
         Mapper.Initialize(cfg => cfg.CreateMap <TestimonialViewModel, TestimonialEntity>());
         var testimonialEntity = Mapper.Map <TestimonialViewModel, TestimonialEntity>(testimonial);
         return(testimonialServices.AddTestimonial(testimonialEntity));
     }
     return(0);
 }
Пример #8
0
 public IActionResult Create(TestimonialViewModel testimonial)
 {
     if (ModelState.IsValid)
     {
         Testimonial model = _mapper.Map <TestimonialViewModel, Testimonial>(testimonial);
         model.AddedBy = "System";
         _contentRepository.CreateTestimonial(model);
         return(RedirectToAction("index"));
     }
     return(View(testimonial));
 }
Пример #9
0
        // GET: Admin/Testimonial/Create
        public ActionResult Create()
        {
            var viewModel = new TestimonialViewModel
            {
                CreatedDate       = DateTime.Now,
                ClientsSelectList = Mapper.Map <List <Client>, List <SelectListItem> >(_clientService.GetAll())
            };

            AddLocales(viewModel.Locales, (locale, languageId) => { });

            return(View(viewModel));
        }
        public ActionResult Search(TestimonialViewModel tViewModel)
        {
            try
            {
            }
            catch (Exception ex)
            {
                tViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Testimonial Controller - Search: " + ex.ToString());
            }
            return(View("Search", tViewModel));
        }
Пример #11
0
 public void OnPost(TestimonialViewModel testimonialvm)
 {
     if (!ModelState.IsValid)
     {
         ErrorMessage = "اطلاعات ثبت نگردید. لطفاً مجدداً تلاش نمائید.";
     }
     else
     {
         _itestimonialapplication.Create(testimonialvm);
         SuccessMessage = "اطلاعات با موفقیت ثبت گردید. با تشکر.";
         ModelState.Clear();
     }
 }
Пример #12
0
        public IActionResult Create(TestimonialViewModel model)
        {
            if (ModelState.IsValid)
            {
                var testimonial = _mapper.Map <TestimonialViewModel, Testimonial>(model);

                testimonial.AddedBy = _admin.Fullname;

                _sectionRepository.CreateTestimonail(testimonial);

                return(RedirectToAction("index"));
            }
            return(View(model));
        }
Пример #13
0
        public ActionResult Edit(TestimonialViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var testimonial = Mapper.Map <TestimonialViewModel, Testimonial>(model);

            testimonial.ModifiedBy   = User.UserId;
            testimonial.ModifiedDate = DateTime.Now;
            testimonial.IsDeleted    = false;
            //process upload an image
            string file_name = string.Empty, file_src = string.Empty;
            var    allowedExtensions = new string[] { ".jpeg", ".jpg", ".png" };
            bool   isAllowed         = true;

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];
                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    if (file.ContentLength > 1048576)
                    {
                        isAllowed = false;
                        break;
                    }
                    file_name = Guid.NewGuid() + Path.GetExtension(fileName);
                    file_src  = Path.Combine(Server.MapPath("~/photo/testimonial/"), file_name);
                    file.SaveAs(file_src);

                    break;
                }
            }
            if (!isAllowed)
            {
                ModelState.AddModelError("", "Bạn chỉ được phép upload file .png và .jpg, hoặc file của bạn có dung lượng nhỏ hơn 2Mb");
                return(View(model));
            }
            if (!string.IsNullOrEmpty(file_name))
            {
                testimonial.Photo = file_name;
            }

            _testimonalRepo.UpdateAndSubmit(testimonial);
            return(RedirectToAction("index"));
        }
Пример #14
0
        public ActionResult AddEdit(int id = 0)
        {
            var model = new TestimonialViewModel {
                HospitalId = ProjectSession.LoggedInUser.HospitalId
            };

            if (id == 0)
            {
                return(View(model));
            }

            model = _testimonialsService.GetById(id);

            return(View(model));
        }
 public TestimonialPage(RootPage rootPage)
 {
     try
     {
         InitializeComponent();
         _model         = new TestimonialViewModel(App.CurrentApp.MainPage.Navigation);
         _model.Root    = rootPage;
         BindingContext = _model;
         Init();
     }
     catch (Exception ex)
     {
         DependencyService.Get <IMessage>().AlertAsync(TextResources.Alert,
                                                       ex.InnerException != null ? ex.InnerException.Message : ex.Message, TextResources.Ok);
     }
 }
Пример #16
0
        public TestimonialViewModel Save(TestimonialViewModel model)
        {
            var testimonial = model.GeTestimonialEntity();

            if (testimonial.Id > 0)
            {
                _iTestimonialsRepository.Update(testimonial);
            }
            else
            {
                _iTestimonialsRepository.Insert(testimonial);
                model.Id = testimonial.Id;
            }

            return(model);
        }
Пример #17
0
 public IActionResult Update(TestimonialViewModel testimonial)
 {
     if (ModelState.IsValid)
     {
         Testimonial model = _mapper.Map <TestimonialViewModel, Testimonial>(testimonial);
         model.ModifiedBy   = "System";
         model.ModifiedDate = DateTime.Now;
         Testimonial testimonialToUpdate = _contentRepository.GetTestimonialById(testimonial.Id);
         if (testimonialToUpdate == null)
         {
             return(NotFound());
         }
         _contentRepository.UpdateTestimonial(testimonialToUpdate, model);
         return(RedirectToAction("index"));
     }
     return(View(testimonial));
 }
Пример #18
0
        public ActionResult <List <TestimonialViewModel> > GetTestimonialForInternship(int id)
        {
            var ratings      = _internshipService.GetInternshipRatings(id);
            var testimonials = new List <TestimonialViewModel>();

            foreach (var rating in ratings)
            {
                var testimonial = new TestimonialViewModel()
                {
                    Firstname   = rating.Student.Firstname,
                    Lastname    = rating.Student.Lastname,
                    Testimonial = rating.Testimonial,
                    Date        = rating.Date.Date.ToShortDateString()
                };
                testimonials.Add(testimonial);
            }
            return(Ok(new { testimonials }));
        }
        public ActionResult Index(TestimonialViewModel tViewModel)
        {
            try
            {
                if (tViewModel.testimonial.Testimonial_Id != 0)
                {
                    tViewModel.testimonial = _testimonialMan.Get_Testimonial_By_Id(tViewModel.testimonial.Testimonial_Id);

                    tViewModel.testimonial.Author_Image_Url = ConfigurationManager.AppSettings["Upload_Image_Path"].ToString() + @"\" + tViewModel.testimonial.File_Type_Str + @"\" + tViewModel.testimonial.Author_Image_Url;
                }
            }
            catch (Exception ex)
            {
                tViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Testimonial Controller - Index: " + ex.ToString());
            }
            return(View("Index", tViewModel));
        }
Пример #20
0
        public IActionResult Edit(TestimonialViewModel model)
        {
            if (ModelState.IsValid)
            {
                var testimonial         = _mapper.Map <TestimonialViewModel, Testimonial>(model);
                var testimonialToUpdate = _sectionRepository.GetTestimonialById(model.Id);
                if (testimonialToUpdate == null)
                {
                    return(NotFound());
                }

                testimonial.ModifiedBy = _admin.Fullname;

                _sectionRepository.UpdateTestimonial(testimonialToUpdate, testimonial);

                return(RedirectToAction("index"));
            }
            return(View(model));
        }
Пример #21
0
        public ActionResult Delete(TestimonialViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = Mapper.Map <TestimonialViewModel, Testimonial>(viewModel);

                    _testimonialService.Delete(entity);

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }

            return(View(viewModel));
        }
Пример #22
0
        public async Task <IActionResult> CreateAsync(TestimonialViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var testimonial = vm.ToModel();

            testimonial.ImageName = await _fileStorageService.SaveFileAsync(vm.FormFile, baseDirectoryLocation : "Testimonial");

            await _context.Testimonials.AddAsync(testimonial);

            await _context.SaveChangesAsync();

            TempData["alert-type"]  = "success";
            TempData["alert-title"] = "congrats";
            TempData["alert-body"]  = "new testimonial created successfully";
            return(LocalRedirect("~/"));
        }
        public ActionResult Save_Testimonial(TestimonialViewModel tViewModel)
        {
            try
            {
                SessionInfo session = new SessionInfo();

                if (Session["SessionInfo"] != null)
                {
                    session = (SessionInfo)Session["SessionInfo"];
                }

                tViewModel.testimonial.Updated_By = session.User_Id;
                tViewModel.testimonial.Updated_On = DateTime.Now;
                tViewModel.testimonial.Created_By = session.User_Id;
                tViewModel.testimonial.Created_On = DateTime.Now;

                if (tViewModel.testimonial.Testimonial_Id != 0)
                {
                    _testimonialMan.Update_Testimonial(tViewModel.testimonial);

                    tViewModel.FriendlyMessage.Add(MessageStore.Get("TST02"));
                }
                else
                {
                    tViewModel.testimonial.Testimonial_Id = _testimonialMan.Insert_Testimonial(tViewModel.testimonial);

                    tViewModel.FriendlyMessage.Add(MessageStore.Get("TST01"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Testimonial Controller - Save_Testimonial: " + ex.ToString());

                tViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));
            }

            return(View("Index", tViewModel));
        }
Пример #24
0
        public ActionResult AddEdit(TestimonialViewModel model, string create = null)
        {
            try
            {
                if (model == null || !ModelState.IsValid)
                {
                    return(View(model));
                }

                if (model.ClientImage != null)
                {
                    model.ClientImagePath = UploadFile(model.ClientImage);
                }

                model.HospitalId = ProjectSession.LoggedInUser.HospitalId;
                model            = _testimonialsService.Save(model);

                // Clear the cache
                _cacheManager.Remove(CacheKeys.TestimonialList.ToString());

                SuccessNotification(Resources.SaveSuccess);

                if (string.IsNullOrEmpty(create))
                {
                    return(RedirectToAction(nameof(Index)));
                }

                return(create.Equals("Save & Continue")
                    ? RedirectToAction(nameof(AddEdit), new { id = model.Id })
                    : RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                Logger.log.Error($"Testimonials > KendoSave. Error: {e.Message}");
                ErrorNotification(Resources.SaveFailed);
                return(View(model));
            }
        }
Пример #25
0
 public void Update(TestimonialViewModel vm)
 {
     Name        = vm.PersonName;
     Designation = vm.Designation;
     Description = vm.Message;
 }