public async Task AddNewAsync(SectionPageViewModel model) { var sPage = _mapper.Map <SectionPage>(model); await _context.AddAsync(sPage); await _context.SaveChangesAsync(); }
public async Task UpdateSectionPageByIdAsync(SectionPageViewModel model) { var spage = await _context.SectionPage.Where(p => p.Id == model.Id).SingleOrDefaultAsync(); if (spage != null) { spage.MediaId = model.MediaId; spage.PageId = model.PageId; spage.Title = model.Title.Trim(); spage.ContentText = model.ContentText.Trim().Substring(0, 500); await _context.SaveChangesAsync(); } }
public ActionResult Index(int page = 1) { int pageSize = 5; var sectionVmList = _mapper.Map <IEnumerable <SectionDto>, List <SectionVm> >(_service.GetSections()); var sectionsPerPage = sectionVmList.Skip((page - 1) * pageSize).Take(pageSize); var pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = sectionVmList.Count }; var vm = new SectionPageViewModel { PageInfo = pageInfo, Sections = sectionsPerPage }; return(View("Index", vm)); }
public async Task <IActionResult> Post(SectionPageViewModel model) { await _spageSerices.AddNewAsync(model); return(Ok()); }
public async Task <IActionResult> Put(SectionPageViewModel model) { await _spageSerices.UpdateSectionPageByIdAsync(model); return(Ok()); }