public async Task <Result <int> > Create(RouteCreateModel item) { try { if (await _userResolver.IsConfirmed()) { string line = $"LINESTRING({item.Line})"; bool isValidLine = _routeRepository.IsValidLine(line); if (isValidLine) { string point = RouteHelper.GetFirstPoint(item.Line); var user = await _userResolver.GetUser(); var infoEntity = new RouteInfoEntity() { Difficulty = item.Difficulty, Name = item.Name, Geometry = new RouteGeomEntity() { Line = line, Status = 1 }, UserId = user.Id, Point = new RoutePointEntity() { Point = $"POINT({point})", Status = 1 } }; _routeRepository.Add(infoEntity); await _routeRepository.Commit(); return(new Result <int>(infoEntity.ID)); } else { ErrorResult error = GenerateError("Invalid route line", "Line", "Invalid geometry", ErrorStatus.InvalidModel); return(new Result <int>(error)); } } else { ErrorResult error = GenerateError("User is not confirmed", "", "", ErrorStatus.Forbidden); return(new Result <int>(error)); } } catch (Exception ex) { ErrorResult error = GenerateError(ex); return(new Result <int>(error)); } }