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)); }
public ActionResult Update(CreateRoleViewModel createRole) { if (ModelState.IsValid) { var roleDto = Mapper.Map <RoleDTO>(createRole); _roleService.EditEntity(roleDto); return(RedirectToAction("Index")); } return(View("Update", createRole)); }
public ActionResult Update(CreatePlatformTypeViewModel createType) { if (ModelState.IsValid) { var typeDto = Mapper.Map <PlatformTypeDTO>(createType); _typeService.EditEntity(typeDto); return(RedirectToAction("Index")); } return(View("Update", createType)); }
public ActionResult Update(CreatePublisherViewModel createPublisher) { if (ModelState.IsValid) { var publisherDto = Mapper.Map <PublisherDTO>(createPublisher); _publisherService.EditEntity(publisherDto); return(RedirectToAction("Index")); } return(View("Update", createPublisher)); }
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)); }
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); }
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); }
public void EditGenreItemSentToDAL_InvalidItemWithLists() { // Act Assert.Throws <ArgumentNullException>(() => _genreService.EditEntity(new GenreDTO())); }