예제 #1
0
 public ActionResult Update(CreateGenreViewModel createGenre)
 {
     if (ModelState.IsValid)
     {
         var genreDto = Mapper.Map <GenreDTO>(createGenre);
         _genreService.EditEntity(genreDto);
         return(RedirectToAction("Index"));
     }
     createGenre.AllGenres = Mapper.Map <IEnumerable <GenreViewModel> >(_genreService.GetAll(false));
     return(View("Update", createGenre));
 }
예제 #2
0
        public ActionResult Update(CreateRoleViewModel createRole)
        {
            if (ModelState.IsValid)
            {
                var roleDto = Mapper.Map <RoleDTO>(createRole);
                _roleService.EditEntity(roleDto);
                return(RedirectToAction("Index"));
            }

            return(View("Update", createRole));
        }
예제 #3
0
        public ActionResult Update(CreatePlatformTypeViewModel createType)
        {
            if (ModelState.IsValid)
            {
                var typeDto = Mapper.Map <PlatformTypeDTO>(createType);
                _typeService.EditEntity(typeDto);
                return(RedirectToAction("Index"));
            }

            return(View("Update", createType));
        }
예제 #4
0
        public ActionResult Update(CreatePublisherViewModel createPublisher)
        {
            if (ModelState.IsValid)
            {
                var publisherDto = Mapper.Map <PublisherDTO>(createPublisher);
                _publisherService.EditEntity(publisherDto);
                return(RedirectToAction("Index"));
            }

            return(View("Update", createPublisher));
        }
예제 #5
0
        public HttpResponseMessage Put(string name, [FromBody] CreatePublisherViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            var publisherDto = Mapper.Map <PublisherDTO>(model);

            _publisherService.EditEntity(publisherDto);
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
예제 #6
0
        public void EditPlatform_ItemSentToDAL_ValidItemWithLists()
        {
            // Arrange
            var translate = new PlatformTypeTranslate
            {
                Id        = Guid.NewGuid(),
                IsDeleted = false,
                Language  = Language.en,
                Name      = "name"
            };
            var type = new PlatformType
            {
                Id         = Guid.NewGuid(),
                IsDeleted  = false,
                Translates = new List <PlatformTypeTranslate>
                {
                    translate
                }
            };

            _mock.Setup(a => a.Repository <PlatformType>().GetAll()).Returns(new List <PlatformType>()
            {
                type
            });
            _mock.Setup(a => a.Repository <PlatformTypeTranslate>().GetAll())
            .Returns(new List <PlatformTypeTranslate> {
                translate
            });
            _mock.Setup(a => a.Repository <PlatformType>().Edit(It.IsAny <PlatformType>())).Verifiable();
            _mock.Setup(a => a.Repository <PlatformTypeTranslate>().Edit(It.IsAny <PlatformTypeTranslate>()));
            _mock.Setup(a => a.Repository <PlatformType>().GetSingle(type.Id.ToString())).Returns(type);

            // Act
            _typeService.EditEntity(new PlatformTypeDTO
            {
                Id         = type.Id.ToString(),
                Translates =
                    new List <PlatformTypeDTOTranslate>
                {
                    new PlatformTypeDTOTranslate
                    {
                        Id       = translate.Id.ToString(),
                        Name     = translate.Name,
                        Language = Language.en
                    }
                }
            });
            Mock.Verify(_mock);
        }
예제 #7
0
        public void EditRole_ItemSentToDAL_ValidItemWithLists()
        {
            // Arrange
            var translate = new RoleTranslate
            {
                Id        = Guid.NewGuid(),
                IsDeleted = false,
                Language  = Language.en,
                Name      = "name"
            };
            var role = new Role
            {
                Id         = Guid.NewGuid(),
                IsDeleted  = false,
                Translates = new List <RoleTranslate>
                {
                    translate
                }
            };

            _mock.Setup(a => a.Repository <Role>().GetAll()).Returns(new List <Role>()
            {
                role
            });
            _mock.Setup(a => a.Repository <RoleTranslate>().GetAll()).Returns(new List <RoleTranslate> {
                translate
            });
            _mock.Setup(a => a.Repository <RoleTranslate>().Edit(It.IsAny <RoleTranslate>()));
            _mock.Setup(a => a.Repository <Role>().Edit(It.IsAny <Role>()));
            _mock.Setup(a => a.Repository <Role>().GetSingle(role.Id.ToString())).Returns(role);
            // Act
            _roleService.EditEntity(new RoleDTO
            {
                Id         = role.Id.ToString(),
                Translates =
                    new List <RoleDTOTranslate>
                {
                    new RoleDTOTranslate
                    {
                        Id       = translate.Id.ToString(),
                        Name     = translate.Name,
                        Language = Language.en
                    }
                }
            });
            Mock.Verify(_mock);
        }
예제 #8
0
 public void EditGenreItemSentToDAL_InvalidItemWithLists()
 {
     // Act
     Assert.Throws <ArgumentNullException>(() => _genreService.EditEntity(new GenreDTO()));
 }