public ActionResult Add(TerminationNoticeViewModel termination)
        {
            var notice = new TerminationNotice();

            var username = User.Identity.GetUserName();

            notice.Owner   = this.userService.GetAll().Where(x => x.UserName == username).FirstOrDefault();
            notice.Content = termination.Content;
            notice.Company = new Company
            {
                Name        = termination.Company.Name,
                PhoneNumber = termination.Company.PhoneNumber,
                Email       = termination.Company.Email,
                Address     = new Address
                {
                    Name = termination.Company.Address,
                    Town = new Town
                    {
                        Name       = termination.Company.Town,
                        PostalCode = termination.Company.PostalCode,
                        Country    = new Country {
                            Name = termination.Company.Country
                        }
                    }
                }
            };

            this.terminationNoticeService.Add(notice);
            this.saveContext.Commit();

            return(View(termination));
        }
Exemplo n.º 2
0
        public void CallContextCommit_WhenCalled()
        {
            // Arrange
            var terminationNotice         = new TerminationNotice();
            var terminationNoticeRepoMock = new Mock <IEfRepository <TerminationNotice> >();
            var contextMock = new Mock <ISaveContext>();

            contextMock.Setup(c => c.Commit()).Verifiable();

            var sut = new TerminationNoticeService(terminationNoticeRepoMock.Object, contextMock.Object);

            // Act
            sut.Update(terminationNotice);

            // Assert
            terminationNoticeRepoMock.Verify();
        }
 public void Add(TerminationNotice terminationNotice)
 {
     this.terminationNoticeRepo.Add(terminationNotice);
     this.context.Commit();
 }
 public void Update(TerminationNotice terminationNotice)
 {
     this.terminationNoticeRepo.Update(terminationNotice);
     this.context.Commit();
 }