public IActionResult GetById(int id) { var user = _userService.GetById(id); var userViewModel = GenericMapper.MapObject <FullUserViewModel>(user); return(Ok(userViewModel)); }
public FullImageObjectViewModel Create(FullImageObjectViewModel image) { var result = new FullImageObjectViewModel(); var createdEntity = _imageObjectsService.UploadImage(image.Content, image.Name, image.Description, HttpContext.User.Identity.Name); if (createdEntity != null) { result = GenericMapper.MapObject <FullImageObjectViewModel>(createdEntity); } return(result); }
public FullPageViewModel Create(FullPageViewModel page) { var result = new FullPageViewModel(); var newEntity = GenericMapper.MapObject <Page>(page); var createdEntity = _pagesService.Create(newEntity); if (createdEntity != null) { result = GenericMapper.MapObject <FullPageViewModel>(createdEntity); } return(result); }
public FullPostViewModel Create(FullPostViewModel page) { var result = new FullPostViewModel(); var newEntity = GenericMapper.MapObject <Post>(page); var createdEntity = _postsService.Create(newEntity, HttpContext.User.Identity.Name); if (createdEntity != null) { result = GenericMapper.MapObject <FullPostViewModel>(createdEntity); } return(result); }
public IActionResult CreateAdminUser([FromBody] FullUserViewModel model) { // map dto to entity var user = GenericMapper.MapObject <User>(model); try { // save _userService.CreateAdminUser(user, model.Password); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public void Update(int id, FullPageViewModel page) { var updatedEntity = GenericMapper.MapObject <Page>(page); _pagesService.Update(id, updatedEntity); }