public ActionResult <VlogDetailsViewModel> Details(int id, TranslationLanguage?language = null) { var vm = this.manager.GetQueryById(id) .Select(VlogDetailsViewModel.FromEntity(language ?? base.AppSettings.DefaultLanguage)) .FirstOrDefault(); return(vm); }
public ActionResult <ISearchResultModel <VlogDetailsViewModel> > Index(ISearchVlogModel search) { var result = this.manager.SearchVlogs(search); var vm = new SearchResultModel <VlogDetailsViewModel>() { List = result.List.Select(VlogDetailsViewModel.FromEntity(search.Language ?? base.AppSettings.DefaultLanguage)), Page = result.Page, PageCount = result.PageCount, PageSize = result.PageSize, TotalCount = result.TotalCount }; return(vm); }
public async Task <ActionResult <OkObjectViewModel <VlogDetailsViewModel> > > Update(UpdateVlogViewModel model) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(new BadRequestViewModel <ModelStateError>(ModelState.GetErrors()))); } var result = await this.manager.UpdateVlogAsync(model); if (!result.Succeeded) { AddManagerErrorsToModelState(result.Errors); return(new BadRequestObjectResult(new BadRequestViewModel <ModelStateError>(ModelState.GetErrors()))); } var vm = this.manager.GetQueryById(result.Model.Id) .Select(VlogDetailsViewModel.FromEntity(AppSettings.DefaultLanguage)) .FirstOrDefault(); base.Response.StatusCode = (int)HttpStatusCode.Created; return(new OkObjectViewModel <VlogDetailsViewModel>("Success", vm)); }