Exemple #1
0
        public IHttpActionResult Post(ActivityCategoryDTO category)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var existingCategory = uow.ActivityCategoryRepository
                                       .GetQuery()
                                       .Where(x => x.Name == category.Name)
                                       .FirstOrDefault();

                ActivityCategoryDTO model;

                if (existingCategory != null)
                {
                    existingCategory.IconPath = category.IconPath;
                    existingCategory.Type     = category.Type;
                    model = Mapper.Map <ActivityCategoryDTO>(existingCategory);
                }
                else
                {
                    var entity = Mapper.Map <ActivityCategoryDO>(category);
                    entity.Id = Guid.NewGuid();

                    uow.ActivityCategoryRepository.Add(entity);
                    model = Mapper.Map <ActivityCategoryDTO>(entity);
                }

                uow.SaveChanges();

                return(Ok(model));
            }
        }
Exemple #2
0
        public static ActivityCategoryDTO BasicWebServiceDTOWithoutId()
        {
            var webServiceDTO = new ActivityCategoryDTO
            {
                Name     = "IntegrationTestWebService",
                IconPath = "IntegrationTestIconPath"
            };

            return(webServiceDTO);
        }