public Dictionary <User, bool> SearchChipFood(IConnectionHandler connectionHandler, Guid congressId, Guid chipFoodId, string txtSearch, User user, EnterpriseNode.Tools.Enums.Gender gender, FormStructure formStructure) { var outlist = new Dictionary <User, bool>(); var search = new UserBO().Search(connectionHandler, congressId, txtSearch, user, Enums.AscendingDescending.Descending, Enums.SortAccordingToUser.RegisterDate, gender, formStructure); var chipsFoodUserBo = new ChipsFoodUserBO(); var @select = chipsFoodUserBo.Select(connectionHandler, x => x.UserId, x => x.ChipsFoodId == chipFoodId); foreach (var item in search) { var chipsFoodUsers = @select.Any(x => x.Equals(item.Id)); outlist.Add(item, chipsFoodUsers); } return(outlist); }
public bool JoinUser(IConnectionHandler connectionHandler, Guid chipsFoodid, List <Guid> list) { var chipsFoodBo = new ChipsFoodBO(); var food = chipsFoodBo.Get(connectionHandler, chipsFoodid); if (food == null || food.Capacity == 0) { throw new Exception(Resources.Congress.Capacityisnotenough); } var chipsFoods = new ChipsFoodUserBO().Where(connectionHandler, x => x.ChipsFoodId == chipsFoodid); foreach (var guid in list) { var chipsFoodUser = new ChipsFoodUserBO().Get(connectionHandler, chipsFoodid, guid); if (chipsFoodUser == null) { var foodUser = new ChipsFoodUser { UserId = guid, ChipsFoodId = chipsFoodid }; if (!new ChipsFoodUserBO().Insert(connectionHandler, foodUser)) { throw new Exception(Resources.Congress.ErrorInSaveChipFood); } food.Capacity--; } } foreach (var chipsFood in chipsFoods) { if (list.All(x => x != chipsFood.UserId)) { if (!new ChipsFoodUserBO().Delete(connectionHandler, chipsFoodid, chipsFood.UserId)) { throw new Exception(Resources.Congress.ErrorInSaveChipFood); } food.Capacity++; } } if (!chipsFoodBo.Update(connectionHandler, food)) { throw new Exception(Resources.Congress.ErrorInSaveChipFood); } return(true); }
public ModelView.UserCardModel SearchChipFoodReport(Guid chipfoodId, Guid userId) { try { var userCardModels = new ModelView.UserCardModel(); var userBo = new UserBO(); var user = userBo.Get(this.ConnectionHandler, userId); var config = new ConfigurationBO().Get(this.ConnectionHandler, user.CongressId); var configcontent = new ConfigurationContentBO().Get(this.ConnectionHandler, user.CongressId, config.CardLanguageId); var homa = new HomaBO().Get(this.ConnectionHandler, user.CongressId); var chipsFoodUserBo = new ChipsFoodUserBO(); var chipsFoodUsers = chipsFoodUserBo.Get(this.ConnectionHandler, chipfoodId, user.Id); var chipsFoodBo = new ChipsFoodBO(); if (chipsFoodUsers != null) { var chipsFood = chipsFoodBo.Get(this.ConnectionHandler, chipsFoodUsers.ChipsFoodId); var cardModels = userBo.GetChipFootUser(this.ConnectionHandler, user, configcontent, homa, new List <ChipsFood> { chipsFood }); if (cardModels.Count > 0) { userCardModels = cardModels.FirstOrDefault(); } } return(userCardModels); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }