public void IsReturnTypeCorrect() { var actual = ErrorService.GetError("test"); var expected = typeof(Error); Assert.IsType(expected, actual); }
public IActionResult Index() { var feature = HttpContext.Features.Get <IExceptionHandlerPathFeature>(); var errorResponse = errorService.GetError(feature); return(View(errorResponse.ErrorView, errorResponse)); }
public ActionResult edtiEventInformation(int?id, [FromBody] EventUpdateFrom @event) { if (validationService.objectValidation(eventsService.getEventById(id.Value))) { return(Ok(eventsService.editEventInformation(id.Value, @event.title, @event.summary))); } return(NotFound(ErrorService.GetError("event is not found"))); }
public ActionResult GetAll() { if (supportService.getAllSuportsCount() > 0) { return(Ok(supportService.getAllSuports())); } return(NotFound(ErrorService.GetError("Support message list not found"))); }
public ActionResult GetAll() { if (eventsService.getAllEventsCount() > 0) { return(Ok(eventsService.getAllEvents())); } return(NotFound(ErrorService.GetError("0 events was found"))); }
public ActionResult GetAll() { if (userService.getListLength() > 0) { return(Ok(userService.getAllUsers())); } return(NotFound(ErrorService.GetError("Users list is empty"))); }
public ActionResult deleteEvent(int id) { if (validationService.objectValidation(eventsService.getEventById(id))) { eventsService.deleteEvent(id); return(NoContent()); } return(NotFound(ErrorService.GetError("Event not found"))); }
public ActionResult deleteSupportMessage(int?id) { if (validationService.objectValidation(supportService.getSupportById(id.Value))) { supportService.deleteSupportFromDatabase(id.Value); return(NoContent()); } return(NotFound(ErrorService.GetError("Id not null or dont exists"))); }
public ActionResult Register([FromBody] UserRegisterModel userRegisterModel) { if (validationService.textValidation(userRegisterModel.Name) && validationService.textValidation(userRegisterModel.Password) && validationService.emailValidation(userRegisterModel.Email)) { return(Ok(authService.createNewUser(userRegisterModel.Name, userRegisterModel.Password))); } return(NotFound(ErrorService.GetError("Username, password or email is not valid"))); }
public ActionResult writeSolution(int?id, string message, int?solvedBy) { if (validationService.objectValidation(supportService.getSupportById(id.Value)) && validationService.textValidation(message) && validationService.idValdation(solvedBy)) { supportService.updateSupport(id.Value, solvedBy.Value, message); return(Ok(supportService.getSupportById(id.Value))); } return(NotFound(ErrorService.GetError("id, message and solved by can not be empty"))); }
public ActionResult banUser(int?id) { User user = userService.getUserById(id.Value); if (validationService.idValdation(id) && validationService.objectValidation(user)) { userService.BanOrUnban(user); return(Ok(user)); } return(NotFound(ErrorService.GetError("User not found"))); }
public ActionResult deleteUser(int?id) { User user = userService.getUserById(id.Value); if (validationService.idValdation(id) && validationService.objectValidation(user)) { userService.deleteUserById(id.Value); return(NoContent()); } return(NotFound(ErrorService.GetError("User not found"))); }
public ActionResult GetById(int?id) { if (validationService.idValdation(id)) { if (validationService.objectValidation(userService.getUserById(id.Value))) { return(Ok(userService.getUserById(id.Value))); } return(NotFound(ErrorService.GetError("User not found"))); } return(NotFound(ErrorService.GetError("Id is wrong"))); }
public ActionResult findUser([FromBody] UserRegisterModel userRegisterModel) { if (validationService.textValidation(userRegisterModel.Name) && validationService.textValidation(userRegisterModel.Password)) { if (validationService.objectValidation(userService.getUserByNameAndPassword(userRegisterModel.Name, userRegisterModel.Password))) { return(Ok(userService.getUserByNameAndPassword(userRegisterModel.Name, userRegisterModel.Password))); } return(NotFound(ErrorService.GetError("User not found"))); } return(NotFound(ErrorService.GetError("User does not exists"))); }
public ActionResult getUserEvents(int?userId) { if (validationService.idValdation(userId)) { if (userEventsService.getUserEventsByParticipanIdCount(userId.Value) > 0) { return(Ok(userEventsService.getUserEventsByParticipanId(userId.Value))); } return(NotFound(ErrorService.GetError("0 events were found"))); } return(NotFound(ErrorService.GetError("user id not found"))); }
public ActionResult getEventById(int?id) { if (validationService.idValdation(id)) { if (validationService.objectValidation(eventsService.getEventById(id.Value))) { return(Ok(eventsService.getEventById(id.Value))); } return(NotFound(ErrorService.GetError("Event not found"))); } return(NotFound(ErrorService.GetError("Wrong id"))); }
public ActionResult GetById(int?id) { if (validationService.idValdation(id)) { if (validationService.objectValidation(supportService.getSupportById(id.Value))) { return(Ok(supportService.getSupportById(id.Value))); } return(NotFound(ErrorService.GetError("Support not found"))); } return(NotFound(ErrorService.GetError("Support id not found"))); }
public ActionResult deleteUserEvent(int?userId, int?eventId) { if (validationService.idValdation(userId) && validationService.idValdation(eventId)) { if (validationService.objectValidation(userEventsService.getEventByUserIdAndEventId(userId.Value, eventId.Value))) { userEventsService.deleteUserEvent(userId.Value, eventId.Value); return(NoContent()); } return(NotFound(ErrorService.GetError("event not found"))); } return(NotFound(ErrorService.GetError("user or event id not found"))); }
public ActionResult joinEvent(int?userId, int?eventId) { if (validationService.idValdation(userId) && validationService.idValdation(eventId)) { if (validationService.objectValidation(userService.getUserById(userId.Value)) && validationService.objectValidation(eventService.getEventById(eventId.Value))) { return(Ok(userEventsService.joinUserToEvent(userId.Value, eventId.Value))); } return(NotFound(ErrorService.GetError("user or event id not found"))); } return(NotFound(ErrorService.GetError("user or event id not found"))); }
public ActionResult createNewEvent([FromBody] Event @event) { if (validationService.textValidation(@event.title) && validationService.textValidation(@event.summary) && validationService.idValdation(@event.CreatedBy)) { if (validationService.objectValidation(userService.getUserById(@event.CreatedBy))) { return(Ok(eventsService.createNewEvent(@event.title, @event.summary, @event.CreatedBy))); } return(NotFound(ErrorService.GetError("user does not exist"))); } return(NotFound(ErrorService.GetError("title summary and createdBy can not be empty"))); }
public ActionResult createSupportMessage([FromBody] Support support) { if (validationService.idValdation(support.WritenBy) && validationService.textValidation(support.Title) && validationService.textValidation(support.Summary)) { if (validationService.objectValidation(support)) { supportService.AddSupportToDatabase(support); return(Created("", support)); } return(NotFound(ErrorService.GetError("User can not be found"))); } return(NotFound(ErrorService.GetError("UserId, Title and summary can not be empty"))); }
public ActionResult login(string userName, string password) { var header = Request.Headers["Authorization"]; if (validationService.startsWithValidation(header, "Basic")) { var userNameAndPassword = authService.getNameAndPassword(header.ToString()); if (validationService.objectValidation(userService.getUserByNameAndPassword(userNameAndPassword[0], userNameAndPassword[1]))) { return(Ok(authService.getToken(userNameAndPassword[0]))); } return(NotFound(ErrorService.GetError("user not found"))); } return(BadRequest(ErrorService.GetError("Something wrong with header"))); }
public void IsMessageCorrect() { string message = ErrorService.GetError("testMessage").message; Assert.Equal("testMessage", message); }