Пример #1
0
        public void Add_Ok_Test()
        {
            var rndString = Guid.NewGuid().ToString();
            var interest  = _context.Interests.First();
            var city      = _context.Cities.First();
            var result    = _activityOperations.AddAsync(new Activity()
            {
                Name        = rndString,
                Address     = rndString,
                AgeFrom     = 1,
                AgeTo       = 20,
                Description = rndString,
                InterestId  = interest.Id,
                IsChecked   = false,
                Mentor      = rndString,
                Organizer   = new Organizer
                {
                    Name     = rndString,
                    CityId   = city.Id,
                    Sobriety = true,
                    Email    = "*****@*****.**",
                    Phone    = "77777"
                },
                Phones = rndString,
                Prices = rndString
            }).Result;

            Assert.AreEqual(rndString, result.Organizer.Name);
            Assert.AreEqual(rndString, result.Address);
        }
Пример #2
0
        public async Task <IHttpActionResult> Post(ActivityViewModelPost postViewModel)
        {
            try
            {
                var activity = Mapper.Map <Activity>(postViewModel);
                var result   = await _activityOperations.AddAsync(activity);

                await _pictureOperations.SaveByFormIdAsync(postViewModel.FormId, result.Id, LinkedObjectType.Activity);

                return(await Get(result.Id));
            }
            catch (Exception ex)
            {
                ErrorLogger.Log("CANNOT POST ACTIVITY", ex);
                throw;
            }
        }