public Result <User> UpdateUser(User user) { Result <User> retVal = null; try { User userToUpdate = Uow.Users.GetById(user.UserID); userToUpdate.FirstName = user.FirstName; userToUpdate.LastName = user.LastName; userToUpdate.EmailAddress = user.EmailAddress; userToUpdate.Gender = user.Gender; Uow.Users.Update(userToUpdate, userToUpdate.UserID); Uow.Commit(); retVal = ResultHandler <User> .Sucess(userToUpdate); } catch (Exception ex) { log.Error(String.Format("Error updating user, userID: {0}", user.UserID), ex); retVal = ResultHandler <User> .Erorr("Error updating user"); } return(retVal); }
public Result <Match> AddMatch(int userID, Match match) { Result <Match> retVal = null; try { foreach (CompetitorScore competitorScore in match.Scores) { if (competitorBusiness.CheckUserCompetitor(userID, competitorScore.CompetitorID)) { competitorScore.Confirmed = true; } else if (automaticConfirmationsBusiness.CheckConfirmation(userID, competitorScore.CompetitorID)) { competitorScore.Confirmed = true; } } match.CreatorID = userID; match.WinnerID = match.Scores.OrderByDescending(s => s.Score).First().CompetitorID; match.Status = match.Scores.Count(s => !s.Confirmed) > 0 ? MatchStatus.Submited : MatchStatus.Confirmed; Uow.Matches.Add(match); Uow.Commit(); retVal = ResultHandler <Match> .Sucess(match); } catch (Exception ex) { log.Error("Error adding match", ex); retVal = ResultHandler <Match> .Erorr("Error adding match"); } return(retVal); }
public Result <GameCategory> UpdateGameCategory(GameCategory gameCategory) { Result <GameCategory> retVal = null; try { if (CheckExisting(gameCategory)) { retVal = ResultHandler <GameCategory> .Erorr("Duplicate game category"); } else { Uow.GameCategories.Update(gameCategory, gameCategory.GameCategoryID); Uow.Commit(); retVal = ResultHandler <GameCategory> .Sucess(gameCategory); } } catch (Exception ex) { log.Error("Error updating game category", ex); retVal = ResultHandler <GameCategory> .Erorr("Error updating game category"); } return(retVal); }
public Result <List <GameCategory> > FilterByUser(int userID) { Result <List <GameCategory> > retVal = null; try { List <GameCategory> categories = Uow.Competitors .GetAll() .OfType <Player>() .Where(p => p.UserID == userID) .SelectMany(p => p.Games) .Select(g => g.Game.Category) .Distinct() .ToList(); retVal = ResultHandler <List <GameCategory> > .Sucess(categories); } catch (Exception ex) { log.Error("Error retreiving game categories list", ex); retVal = ResultHandler <List <GameCategory> > .Erorr("Error retreiving game categories list"); } return(retVal); }
public Result <Game> AddGame(Game game) { Result <Game> retVal = null; try { if (CheckExisting(game)) { retVal = ResultHandler <Game> .Erorr("Duplicate game"); } else { Uow.Games.Add(game); Uow.Commit(); retVal = ResultHandler <Game> .Sucess(game); } } catch (Exception ex) { log.Error("Error creating game", ex); retVal = ResultHandler <Game> .Erorr("Error creating game"); } return(retVal); }
public Result <Game> GetById(int gameID) { Result <Game> retVal = null; try { Game game = Uow.Games.GetById(gameID); GameCategory category = Uow.GameCategories.GetById(game.GameCategoryID); if (!String.IsNullOrEmpty(game.PictureUrl)) { game.PictureUrl += String.Format("?nocache={0}", DateTime.Now.Ticks); } else if (!String.IsNullOrEmpty(category.PictureUrl)) { game.PictureUrl = String.Format("{0}?nocache={1}", category.PictureUrl, DateTime.Now.Ticks); } retVal = ResultHandler <Game> .Sucess(game); } catch (Exception ex) { log.Error(String.Format("Error retreiving game. ID: {0}", gameID), ex); retVal = ResultHandler <Game> .Erorr("Error retreiving game"); } return(retVal); }
public Result <List <Playground.Model.Playground> > SearchInArea(Location startLocation, Location endLocation, int maxResults) { Result <List <Playground.Model.Playground> > retVal = null; try { List <Playground.Model.Playground> result = Uow.PlaygroundUsers .GetAll() .Where(pgu => pgu.Playground.Latitude >= startLocation.Latitude && pgu.Playground.Latitude <= endLocation.Latitude && pgu.Playground.Longitude >= startLocation.Longitude && pgu.Playground.Longitude <= endLocation.Longitude) .GroupBy(g => g.Playground) .Select(pgr => new { Playground = pgr.Key, UserCount = pgr.Count() }) .OrderByDescending(pgr => pgr.UserCount) .Take(maxResults) .Select(pgr => pgr.Playground) .ToList(); retVal = ResultHandler <List <Playground.Model.Playground> > .Sucess(result); } catch (Exception ex) { log.Error("Error searching playgrounds", ex); retVal = ResultHandler <List <Playground.Model.Playground> > .Erorr("Error searching playgrounds"); } return(retVal); }
public Result <Playground.Model.Playground> AddPlayground(Playground.Model.Playground playground) { Result <Playground.Model.Playground> retVal = null; try { playground.CreationDate = DateTime.Now; Uow.Playgrounds.Add(playground); Uow.Commit(); PlaygroundUser playgroundUser = new PlaygroundUser() { UserID = playground.OwnerID, PlaygroundID = playground.PlaygroundID }; AddUserToPlaygroound(playgroundUser); retVal = ResultHandler <Playground.Model.Playground> .Sucess(playground); } catch (Exception ex) { log.Error("Erorr adding playgorund", ex); retVal = ResultHandler <Playground.Model.Playground> .Erorr("Error adding playground"); } return(retVal); }
public Result <AutomaticMatchConfirmation> AddConfirmation(int userID, int confirmeeID) { Result <AutomaticMatchConfirmation> retVal = null; try { AutomaticMatchConfirmation amc = new AutomaticMatchConfirmation() { ConfirmeeID = confirmeeID, ConfirmerID = userID }; Uow.AutomaticMatchConfirmations.Add(amc); Uow.Commit(); retVal = ResultHandler <AutomaticMatchConfirmation> .Sucess(amc); } catch (Exception ex) { log.Error("Error adding automatic match confrimation", ex); retVal = ResultHandler <AutomaticMatchConfirmation> .Erorr("Error adding automatic match confrimation"); } return(retVal); }
public Result <Playground.Model.ViewModel.Playground> GetById(int playgroundID, int userID) { Result <Playground.Model.ViewModel.Playground> retVal = null; try { Playground.Model.Playground playground = Uow.Playgrounds.GetById(playgroundID); bool isOwner = playground.OwnerID == userID; bool isMember = Uow.PlaygroundUsers.GetAll().Any(pgu => pgu.PlaygroundID == playgroundID && pgu.UserID == userID); Playground.Model.ViewModel.Playground playgorundVM = new Model.ViewModel.Playground() { PlaygroundID = playground.PlaygroundID, Address = playground.Address, Latitude = playground.Latitude, Longitude = playground.Longitude, Name = playground.Name, IsMember = isMember, IsOwner = isOwner }; retVal = ResultHandler <Playground.Model.ViewModel.Playground> .Sucess(playgorundVM); } catch (Exception ex) { log.Error("Error getting playground", ex); retVal = ResultHandler <Playground.Model.ViewModel.Playground> .Erorr("Error loading playgrond"); } return(retVal); }
public Result <List <GameCompetitionType> > FilterByGameAvailable(int gameID) { Result <List <GameCompetitionType> > retVal = null; try { List <GameCompetitionType> competitionTypes = new List <GameCompetitionType>(); IQueryable <CompetitionType> availableCompetitionTypes = Uow.CompetitionTypes .GetAll() .Where(ct => !ct.Games.Any(g => g.GameID == gameID)) .Distinct(); foreach (CompetitionType ct in availableCompetitionTypes) { competitionTypes.Add(new GameCompetitionType() { CompetitionType = ct, CompetitionTypeID = ct.CompetitionTypeID, GameID = gameID }); } retVal = ResultHandler <List <GameCompetitionType> > .Sucess(competitionTypes); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of available competition types for gameID: {0}", gameID), ex); retVal = ResultHandler <List <GameCompetitionType> > .Erorr("Error retreiving list of available competition types for game"); } return(retVal); }
public Result <PagedResult <Game> > SearchAvailableByPlayground(int page, int count, int playgroundID, string search) { Result <PagedResult <Game> > retVal = null; try { List <int> gameIds = Uow.PlaygroundGames .GetAll() .Where(pgg => pgg.PlaygroundID == playgroundID) .Select(g => g.GameID) .ToList(); int totalItems = Uow.Games .GetAll() .Where(g => !gameIds.Contains(g.GameID) && (g.Title.Contains(search) || g.Category.Title.Contains(search))) .Count(); page = GetPage(totalItems, page, count); List <Game> games = Uow.Games .GetAll() .Where(g => !gameIds.Contains(g.GameID) && (g.Title.Contains(search) || g.Category.Title.Contains(search))) .OrderBy(g => g.Title) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (Game game in games) { game.Category = Uow.GameCategories.GetById(game.GameCategoryID); } PagedResult <Game> result = new PagedResult <Game>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = games }; retVal = ResultHandler <PagedResult <Game> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of available games for playground. playgroundID: {0}, search: {1}", playgroundID, search), ex); retVal = ResultHandler <PagedResult <Game> > .Erorr("Error retreiving list of games for category"); } return(retVal); }
public Result <PagedResult <User> > GetUsers(int page, int count) { Result <PagedResult <User> > retVal = null; try { int totalItems = Uow.Users .GetAll() .Count(); page = GetPage(totalItems, page, count); List <User> users = Uow.Users .GetAll() .OrderBy(u => u.FirstName) .ThenBy(u => u.LastName) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (User user in users) { if (!String.IsNullOrEmpty(user.PictureUrl)) { user.PictureUrl += String.Format("?nocache={0}", DateTime.Now.Ticks); } else { user.PictureUrl = user.Gender == Gender.Male ? Constants.Images.DefaultProfileMale : Constants.Images.DefaultProfileFemale; } } PagedResult <User> result = new PagedResult <User>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = users }; retVal = ResultHandler <PagedResult <User> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of users. page: {0}, count: {1}", page, count), ex); retVal = ResultHandler <PagedResult <User> > .Erorr("Error retreiving users"); } return(retVal); }
public Result <PagedResult <Playground.Model.ViewModel.PlaygroundUser> > FilterByPlayground(int page, int count, int playgroundID) { Result <PagedResult <Playground.Model.ViewModel.PlaygroundUser> > retVal = null; try { int totalItems = Uow.PlaygroundUsers .GetAll() .Where(u => u.PlaygroundID == playgroundID) .Count(); page = GetPage(totalItems, page, count); Playground.Model.Playground playground = Uow.Playgrounds.GetById(playgroundID); List <Playground.Model.ViewModel.PlaygroundUser> users = Uow.PlaygroundUsers .GetAll() .Where(u => u.PlaygroundID == playgroundID) .Select(u => u.User) .OrderBy(u => u.FirstName) .ThenBy(u => u.LastName) .Skip((page - 1) * count) .Take(count) .Select(u => new Playground.Model.ViewModel.PlaygroundUser() { UserID = u.UserID, FirstName = u.FirstName, LastName = u.LastName, PictureUrl = u.PictureUrl, IsOwner = u.UserID == playground.OwnerID }) .ToList(); PagedResult <Playground.Model.ViewModel.PlaygroundUser> result = new PagedResult <Playground.Model.ViewModel.PlaygroundUser>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = users }; retVal = ResultHandler <PagedResult <Playground.Model.ViewModel.PlaygroundUser> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error loading users by playgorund. playgroundID: {0}", playgroundID), ex); retVal = ResultHandler <PagedResult <Playground.Model.ViewModel.PlaygroundUser> > .Erorr("Error loading users by playgorund"); } return(retVal); }
public Result <PagedResult <User> > SearchAvailableByPlayground(int page, int count, int playgroundID, string search) { Result <PagedResult <User> > retVal = null; try { List <int> userIds = Uow.PlaygroundUsers .GetAll() .Where(pgu => pgu.PlaygroundID == playgroundID) .Select(u => u.UserID) .ToList(); int totalItems = Uow.Users .GetAll() .Where(u => !userIds.Contains(u.UserID) && (u.FirstName.Contains(search) || u.LastName.Contains(search))) .Count(); page = GetPage(totalItems, page, count); List <User> users = Uow.Users .GetAll() .Where(u => !userIds.Contains(u.UserID) && (u.FirstName.Contains(search) || u.LastName.Contains(search))) .OrderBy(u => u.FirstName) .ThenBy(u => u.LastName) .Skip((page - 1) * count) .Take(count) .ToList(); PagedResult <User> result = new PagedResult <User>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = users }; retVal = ResultHandler <PagedResult <User> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of available users for playground. playgroundID: {0}, search: {1}", playgroundID, search), ex); retVal = ResultHandler <PagedResult <User> > .Erorr("Error retreiving list of available users for playground"); } return(retVal); }
public Result <PagedResult <Match> > FilterByUser(int page, int count, int userID) { Result <PagedResult <Match> > retVal = null; try { List <long> competitorIds = competitorBusiness.GetCompetitorIdsForUser(userID); int totalItems = Uow.Matches .GetAll() .Where(m => m.Scores .Any(s => competitorIds.Contains(s.CompetitorID))) .Count(); page = GetPage(totalItems, page, count); List <Match> matches = Uow.Matches .GetAll(m => m.Winner, m => m.Game, m => m.Scores) .Where(m => m.Scores .Any(s => competitorIds.Contains(s.CompetitorID))) .OrderByDescending(s => s.Date) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (CompetitorScore competitorScore in matches.SelectMany(m => m.Scores)) { competitorScore.Competitor = Uow.Competitors.GetById(competitorScore.CompetitorID); competitorScore.Competitor.IsCurrentUserCompetitor = competitorIds.Contains(competitorScore.Competitor.CompetitorID); } PagedResult <Match> result = new PagedResult <Match>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = matches }; retVal = ResultHandler <PagedResult <Match> > .Sucess(result); } catch (Exception ex) { log.Error("Error getting list of matches", ex); retVal = ResultHandler <PagedResult <Match> > .Erorr("Error getting list of matches"); } return(retVal); }
public Result <PagedResult <User> > SearchAndExcludeByAutomaticConfirmation(int page, int count, int userID, string search) { Result <PagedResult <User> > retVal = null; try { int totalItems = Uow.Users .GetAll() .Except( Uow.AutomaticMatchConfirmations.GetAll() .Where(ac => ac.ConfirmerID == userID) .Select(ac => ac.Confirmee)) .Where(u => u.UserID != userID && (u.FirstName.Contains(search) || u.LastName.Contains(search))) .Count(); page = GetPage(totalItems, page, count); List <User> users = Uow.Users .GetAll() .Except( Uow.AutomaticMatchConfirmations.GetAll() .Where(ac => ac.ConfirmerID == userID) .Select(ac => ac.Confirmee)) .Where(u => u.UserID != userID && (u.FirstName.Contains(search) || u.LastName.Contains(search))) .OrderBy(u => u.FirstName) .Skip((page - 1) * count) .Take(count) .ToList(); PagedResult <User> result = new PagedResult <User>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = users }; retVal = ResultHandler <PagedResult <User> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of users for automatic confirmation. page: {0}, count: {1}, searhc: {2}", page, count, search), ex); retVal = ResultHandler <PagedResult <User> > .Erorr("Error retreiving users"); } return(retVal); }
public Result <PagedResult <Playground.Model.Playground> > GetPlaygrounds(int page, int count, bool all) { Result <PagedResult <Playground.Model.Playground> > retVal = null; try { int totalItems = all ? Uow.Playgrounds .GetAll() .Count() : Uow.Playgrounds .GetAll() .Where(p => p.Public) .Count(); page = GetPage(totalItems, page, count); var playgrounds = Uow.Playgrounds .GetAll(); if (!all) { playgrounds = playgrounds .Where(p => p.Public); } playgrounds = playgrounds .OrderByDescending(p => p.CreationDate) .Skip((page - 1) * count) .Take(count); PagedResult <Playground.Model.Playground> result = new PagedResult <Playground.Model.Playground>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = playgrounds.ToList() }; retVal = ResultHandler <PagedResult <Playground.Model.Playground> > .Sucess(result); } catch (Exception ex) { log.Error("Error getting playgrounds", ex); retVal = ResultHandler <PagedResult <Playground.Model.Playground> > .Erorr("Error searching competitors"); } return(retVal); }
public Result <CompetitionType> GetById(int id) { Result <CompetitionType> retVal = null; try { CompetitionType competitionType = Uow.CompetitionTypes.GetById(id); retVal = ResultHandler <CompetitionType> .Sucess(competitionType); } catch (Exception ex) { log.Error(String.Format("Error retreiving competition type with following id: {0}", id), ex); retVal = ResultHandler <CompetitionType> .Erorr("Error retreiving competition type"); } return(retVal); }
public Result <PagedResult <Match> > FilterByCompetitor(int page, int count, long competitorID) { Result <PagedResult <Match> > retVal = null; try { int totalItems = Uow.Matches .GetAll(m => m.Winner, m => m.Game, m => m.Scores) .Where(m => m.Status == MatchStatus.Confirmed && m.Scores.Any(s => s.CompetitorID == competitorID)) .Count(); page = GetPage(totalItems, page, count); List <Match> matches = Uow.Matches .GetAll(m => m.Winner, m => m.Game, m => m.Scores) .Where(m => m.Status == MatchStatus.Confirmed && m.Scores.Any(s => s.CompetitorID == competitorID)) .OrderByDescending(s => s.Date) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (CompetitorScore competitorScore in matches.SelectMany(m => m.Scores)) { competitorScore.Competitor = Uow.Competitors.GetById(competitorScore.CompetitorID); } PagedResult <Match> result = new PagedResult <Match>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = matches }; retVal = ResultHandler <PagedResult <Match> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error getting list of matches for competitor, ID: {0}", competitorID), ex); retVal = ResultHandler <PagedResult <Match> > .Erorr("Error getting list of matches for competitor"); } return(retVal); }
public Result <Playground.Model.Playground> GetById(int playgroundID) { Result <Playground.Model.Playground> retVal = null; try { Playground.Model.Playground playground = Uow.Playgrounds.GetById(playgroundID); retVal = ResultHandler <Playground.Model.Playground> .Sucess(playground); } catch (Exception ex) { log.Error("Error getting playground", ex); retVal = ResultHandler <Playground.Model.Playground> .Erorr("Error loading playgrond"); } return(retVal); }
public Result <Match> GetMatchById(long matchID) { Result <Match> retVal = null; try { Match result = Uow.Matches.GetById(matchID); retVal = ResultHandler <Match> .Sucess(result); } catch (Exception ex) { log.Error("Error loading match", ex); retVal = ResultHandler <Match> .Erorr("Error loading match"); } return(retVal); }
public Result <CompetitionType> UpdateCompetitionType(CompetitionType competitionType) { Result <CompetitionType> retVal = null; try { Uow.CompetitionTypes.Update(competitionType, competitionType.CompetitionTypeID); Uow.Commit(); retVal = ResultHandler <CompetitionType> .Sucess(competitionType); } catch (Exception ex) { log.Error("Error updating competition type", ex); retVal = ResultHandler <CompetitionType> .Erorr("Error updating competition type"); } return(retVal); }
public Result <PagedResult <AutomaticMatchConfirmation> > FilterByUser(int page, int count, int userID) { Result <PagedResult <AutomaticMatchConfirmation> > retVal = null; try { int totalItems = Uow.AutomaticMatchConfirmations .GetAll() .Where(ac => ac.ConfirmerID == userID) .Count(); page = GetPage(totalItems, page, count); List <AutomaticMatchConfirmation> confirmations = Uow.AutomaticMatchConfirmations .GetAll(ac => ac.Confirmee, ac => ac.Confirmer) .Where(ac => ac.ConfirmerID == userID) .OrderBy(ac => ac.Confirmee.FirstName) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (AutomaticMatchConfirmation confirmation in confirmations) { userBusiness.SetUserPictureUrl(confirmation.Confirmee); } PagedResult <AutomaticMatchConfirmation> result = new PagedResult <AutomaticMatchConfirmation>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = confirmations }; retVal = ResultHandler <PagedResult <AutomaticMatchConfirmation> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error getting list of automatic confirmations for user. ID: {0}", userID), ex); retVal = ResultHandler <PagedResult <AutomaticMatchConfirmation> > .Erorr("Error getting list of automatic confirmations for user"); } return(retVal); }
public Result <PagedResult <Game> > FilterByPlayground(int page, int count, int playgroundID) { Result <PagedResult <Game> > retVal = null; try { int totalItems = Uow.PlaygroundGames .GetAll() .Where(g => g.PlaygroundID == playgroundID) .Count(); page = GetPage(totalItems, page, count); List <Game> games = Uow.PlaygroundGames .GetAll() .Where(g => g.PlaygroundID == playgroundID) .Select(g => g.Game) .OrderBy(g => g.Title) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (Game game in games) { game.Category = Uow.GameCategories.GetById(game.GameCategoryID); } PagedResult <Game> result = new PagedResult <Game>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = games }; retVal = ResultHandler <PagedResult <Game> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of games for category playground. playgroundid: {0}", playgroundID), ex); retVal = ResultHandler <PagedResult <Game> > .Erorr("Error retreiving list of games for category playground"); } return(retVal); }
public Result <PagedResult <GameCategory> > GetGameCategories(int page, int count) { Result <PagedResult <GameCategory> > retVal = null; try { int totalItems = Uow.GameCategories .GetAll() .Count(); // check for last page page = GetPage(totalItems, page, count); List <GameCategory> categories = Uow.GameCategories.GetAll() .OrderBy(gc => gc.Title) .Skip((page - 1) * count) .Take(count) .ToList(); foreach (GameCategory gameCategory in categories) { if (!String.IsNullOrEmpty(gameCategory.PictureUrl)) { gameCategory.PictureUrl += String.Format("?nocache={0}", DateTime.Now.Ticks); } } PagedResult <GameCategory> result = new PagedResult <GameCategory>() { CurrentPage = page, TotalPages = (totalItems + count - 1) / count, TotalItems = totalItems, Items = categories }; retVal = ResultHandler <PagedResult <GameCategory> > .Sucess(result); } catch (Exception ex) { log.Error(String.Format("Error retreiving list of game categories types. page: {0}, count: {1}", page, count), ex); retVal = ResultHandler <PagedResult <GameCategory> > .Erorr("Error retreiving game categories"); } return(retVal); }
public Result <Playground.Model.Playground> UpdatePlayground(Playground.Model.Playground playground) { Result <Playground.Model.Playground> retVal = null; try { Uow.Playgrounds.Update(playground, playground.PlaygroundID); Uow.Commit(); retVal = ResultHandler <Playground.Model.Playground> .Sucess(playground); } catch (Exception ex) { log.Error("Error updating playground", ex); retVal = ResultHandler <Playground.Model.Playground> .Erorr("Error updating playground"); } return(retVal); }
public Result <User> AddUser(User user) { Result <User> retVal = null; try { Uow.Users.Add(user); Uow.Commit(); retVal = ResultHandler <User> .Sucess(user); } catch (Exception ex) { log.Error(String.Format("Error adding user: {0}", user.UserID), ex); retVal = ResultHandler <User> .Erorr("Error adding user"); } return(retVal); }
public Result <User> GetUserById(int userID) { Result <User> retVal = null; try { User user = Uow.Users.GetById(userID); SetUserPictureUrl(user); retVal = ResultHandler <User> .Sucess(user); } catch (Exception ex) { log.Error(String.Format("Error retreiving user by ID. ID: {0}", userID), ex); retVal = ResultHandler <User> .Erorr("Error retreiving user by email"); } return(retVal); }
public Result <GameCategory> GetById(int id) { Result <GameCategory> retVal = null; try { GameCategory gameCategory = Uow.GameCategories.GetById(id); if (!String.IsNullOrEmpty(gameCategory.PictureUrl)) { gameCategory.PictureUrl += String.Format("?nocache={0}", DateTime.Now.Ticks); } retVal = ResultHandler <GameCategory> .Sucess(gameCategory); } catch (Exception ex) { log.Error(String.Format("Error retreiving game category. id: {0}", id), ex); retVal = ResultHandler <GameCategory> .Erorr("Error retreiving game category"); } return(retVal); }