Exemple #1
0
		public async Task<EditFeedResponse> AddFeedAsync(FeedDto feed)
        {
            var response = new EditFeedResponse();

            try
            {
                var now = DateTime.Now;

                var newFeed = new Feed
                {
                    Class = feed.Class,
                    Mappings = feed.Mappings,
                    Created = now,
                    Updated = now
                };

                var addedArticle = this.feedRepository.Insert(newFeed);
                await this.unitOfWork.CommitAsync();
                response.Status = ResponseStatus.OK;
            }
            catch (Exception ex)
            {
                //this.logService.LogError(ex, new HttpContextWrapper(HttpContext.Current));
                response.Status = ResponseStatus.SystemError;
            }

            return response;
        }
Exemple #2
0
		public async Task AddFeedAsyncTest()
		{
			// arrange
            var unitOfWork = new MockUnitOfWork();
            var feedService = new FeedService(unitOfWork);

			var mappings = new int[] { 5, 2, 3, 1, 4 };

			var feed = new FeedDto
			{
				Class = "TestClass",
				Mappings = string.Join(",", mappings)
			};

			// act
			var result = await feedService.AddFeedAsync(feed);

			// assert
			Assert.AreEqual(ResponseStatus.OK, result.Status);
            var repositoryItems = unitOfWork.FeedRepository.Get().ToList();
            Assert.AreEqual(1, repositoryItems.Count());
		}