public JsonResult <IDtoOutObjects> GetById(DtoInGetById user) { // Jak udělat authenticate //Ukázkové použití validačního frameworku if (ModelState.IsValid) { return(Json(_userModel.GetById(user))); } DtoOutError error = new DtoOutError(); error.Exception = new UserIsNotValidException(); error.Message = "GetById is not valid"; return(Json((IDtoOutObjects)error)); }
public IDtoOutObjects GetById(DtoInGetById dtoInGetById) { DtoOutError error = new DtoOutError(); if (TokenTools.Authentication(dtoInGetById.Token, dtoInGetById.DeviceName)) { User user = _usersRepostiory.FindBy(x => x.Id == dtoInGetById.Id && x.IsDeleted == false).FirstOrDefault(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <User, DtoOutUser>(); }); IMapper mapper = config.CreateMapper(); DtoOutUser dtoOutUser = new DtoOutUser(); mapper.Map(user, dtoOutUser); return(dtoOutUser); } else { NotAuthenticatedException ex = new NotAuthenticatedException(); error.Exception = ex; return(error); } }