public async Task <Result <IList <BucketListModel>, Error> > GetBucketLists() { var bucketListEntity = await _bucketListRepository.GetBucketLists(); var bucketListModel = new List <BucketListModel>(); foreach (var bucketList in bucketListEntity) { var user = await _userRepository.GetById(bucketList.UserId); bucketListModel.Add(BucketListModel.Create(bucketList.Id, bucketList.Name, user.Username)); } return(bucketListModel); }
public async Task login(string userName, string userPassword) { try { ossClient = new OssClient(userName, userPassword); buckets = new BucketListModel(ossClient); await buckets.refreshBuckets(); folders = new FolderListModel(ossClient); } catch (Exception ex) { throw ex; } }
public async Task <Result <BucketListModel, Error> > Add(Guid bucketListId, Guid activityId) { var userId = Guid.Parse(_accessor.HttpContext.User.Claims.First(c => c.Type == "userId").Value); var bucketListExists = (await _bucketListRepository.GetById(bucketListId)) != null; if (!bucketListExists) { return(Result.Failure <BucketListModel, Error>(ErrorsList.UnavailableBucketList)); } var bucketList = await _bucketListRepository.GetByIdWithActivities(bucketListId); if (bucketList == null) { return(Result.Failure <BucketListModel, Error>(ErrorsList.UnavailableBucketList)); } var user = await _userRepository.GetById(bucketList.UserId); if (userId != bucketList.UserId) { return(Result.Failure <BucketListModel, Error>(ErrorsList.UnauthorizedUser)); } // Daca activitatea exista deja in bucketlist se returneaza o eroare. if (bucketList.BucketListActivities.Any(bucketListActivityQuery => bucketListActivityQuery.ActivityId == activityId)) { return(Result.Failure <BucketListModel, Error>(ErrorsList.ActivityInBucketListExists)); } var activity = await _activitiesRepository.GetById(activityId); if (activity == null) { return(Result.Failure <BucketListModel, Error>(ErrorsList.UnavailableActivity)); } var bucketListActivity = new BucketListActivity(bucketListId, activityId); bucketList.AddBucketListActivity(bucketListActivity); _bucketListRepository.Update(bucketList); await _bucketListRepository.SaveChanges(); return(BucketListModel.Create(bucketList.Id, bucketList.Name, user.Username)); }
public BucketListView() { InitializeComponent(); bucketListModel = new BucketListModel(); }