示例#1
0
        public void AddExampleWork_CorrectExample_CallsCreateAndSave()
        {
            _sut = new PhotoService(_exampleWorkRepositoryMock.Object, _diplomaRepositoryMock.Object, _unitOfWorkMock.Object);

            _sut.AddExampleWork(new ExampleWork());

            _exampleWorkRepositoryMock.Verify(m => m.Create(It.IsAny <ExampleWork>()), Times.Once);
            _unitOfWorkMock.Verify(m => m.SaveChanges(), Times.Once);
        }
示例#2
0
        public ActionResult AddExampleWork(ExampleWorkViewModel exampleWork)
        {
            var user = _userService.GetCurrent(User.Identity.Name);

            var exampleWorkToAdd = Mapper.Map <ExampleWorkViewModel, ExampleWork>(exampleWork);

            exampleWorkToAdd.MasterId = user.Master.MasterId;

            using (var binaryReader = new BinaryReader(exampleWork.Photo.InputStream))
            {
                exampleWorkToAdd.Photo = binaryReader.ReadBytes(exampleWork.Photo.ContentLength);
            }

            _photoService.AddExampleWork(exampleWorkToAdd);

            return(RedirectToAction("UserProfile", "User"));
        }