Пример #1
0
        public ConsignmentBusinessModel GetConsignmentByNumber(int number)
        {
            var consignment = this.uow.Consignments.GetAll().SingleOrDefault(c => c.Number == number);
            var mapper      = new ConsignmentMapper();

            return(mapper.Map(consignment));
        }
Пример #2
0
        public void UpdateConsignment(ConsignmentBusinessModel consignment)
        {
            var mapper = new ConsignmentMapper();

            this.uow.Consignments.Update(mapper.Map(consignment));
            this.uow.Commit();
        }
Пример #3
0
        public ConsignmentBusinessModel GetConsignmentById(int id)
        {
            var mapper      = new ConsignmentMapper();
            var consignment = this.uow.Consignments.GetById(id);

            return(mapper.Map(consignment));
        }
Пример #4
0
        public void ConsignmentModelToEntityMappingTest()
        {
            var consignmentModel  = fixture.Create <ConsignmentBusinessModel>();
            var consignmentMapper = new ConsignmentMapper();
            var consignment       = consignmentMapper.Map(consignmentModel);

            Assert.AreEqual(consignmentModel.Id, consignment.Id, "Id is not correct");
            Assert.AreEqual(consignmentModel.ArrivalDate, consignment.ArrivalDate, "ArrivalDate is not correct");
            Assert.AreEqual(consignmentModel.WriteOffDate, consignment.WriteOffDate, "WriteOffDate is not correct");
            Assert.AreEqual(consignmentModel.Item, consignment.Item, "Item is not correct");
        }
 public void UpdateConsignmentTest()
 {
     this.testConsignment = this.fixture.Create<Consignment>();
     this.testConsignment.Id = 1;
     var mapper = new ConsignmentMapper();
     this.consignmentFacade.UpdateConsignment(mapper.Map(this.testConsignment));
     var result = this.consignmentFacade.GetConsignmentById(this.testConsignment.Id);
     Assert.AreEqual(this.testConsignment.Id, result.Id);
     Assert.AreEqual(this.testConsignment.ArrivalDate, result.ArrivalDate);
     Assert.AreEqual(this.testConsignment.WriteOffDate, result.WriteOffDate);
 }
Пример #6
0
        public void UpdateConsignmentTest()
        {
            this.testConsignment    = this.fixture.Create <Consignment>();
            this.testConsignment.Id = 1;
            var mapper = new ConsignmentMapper();

            this.consignmentFacade.UpdateConsignment(mapper.Map(this.testConsignment));
            var result = this.consignmentFacade.GetConsignmentById(this.testConsignment.Id);

            Assert.AreEqual(this.testConsignment.Id, result.Id);
            Assert.AreEqual(this.testConsignment.ArrivalDate, result.ArrivalDate);
            Assert.AreEqual(this.testConsignment.WriteOffDate, result.WriteOffDate);
        }
Пример #7
0
        public void ConsignmentEntityToModelMappingTest()
        {
            var consignment       = fixture.Create <Consignment>();
            var consignmentMapper = new ConsignmentMapper();
            var consignmentModel  = consignmentMapper.Map(consignment);

            Assert.AreEqual(consignment.Id, consignmentModel.Id, "Id is not correct");
            Assert.AreEqual(consignment.Number, consignmentModel.Number, "Number is not correct");
            Assert.AreEqual(consignment.ArrivalDate, consignmentModel.ArrivalDate, "ArrivalDate is not correct");
            Assert.AreEqual(consignment.WriteOffDate, consignmentModel.WriteOffDate, "WriteOffDate is not correct");
            Assert.AreEqual(consignment.Item, consignmentModel.Item, "Item is not correct");
            Assert.IsNotNull(consignmentModel.Inventories);
        }
Пример #8
0
        public ConsignmentBusinessModel CreateConsignment(int itemId, ConsignmentBusinessModel consignment)
        {
            ConsignmentBusinessModel consNew;
            var mapper = new ConsignmentMapper();

            int id = 0;
            using (var uowNew = new LibraryUow())
            {
                var item = uowNew.Items.GetById(itemId);
                var entryConsignment = mapper.Map(consignment);
                entryConsignment.Item = item;
                uowNew.Consignments.Add(entryConsignment);

                uowNew.Commit();
                id = entryConsignment.Id;
            }

            consNew = mapper.Map(this.uow.Consignments.GetById(id));
            consignment.Id = consNew.Id;
            consignment.Number = consNew.Number;
            return consNew;
        }
Пример #9
0
        public ConsignmentBusinessModel CreateConsignment(int itemId, ConsignmentBusinessModel consignment)
        {
            ConsignmentBusinessModel consNew;
            var mapper = new ConsignmentMapper();

            int id = 0;

            using (var uowNew = new LibraryUow())
            {
                var item             = uowNew.Items.GetById(itemId);
                var entryConsignment = mapper.Map(consignment);
                entryConsignment.Item = item;
                uowNew.Consignments.Add(entryConsignment);

                uowNew.Commit();
                id = entryConsignment.Id;
            }

            consNew            = mapper.Map(this.uow.Consignments.GetById(id));
            consignment.Id     = consNew.Id;
            consignment.Number = consNew.Number;
            return(consNew);
        }
Пример #10
0
        public ConsignmentBusinessModel GetConsignmentByNumber(int number)
        {
            var consignment = this.uow.Consignments.GetAll().SingleOrDefault(c => c.Number == number);
            var mapper = new ConsignmentMapper();
            return mapper.Map(consignment);

        }
Пример #11
0
 public void UpdateConsignment(ConsignmentBusinessModel consignment)
 {
     var mapper = new ConsignmentMapper();
     this.uow.Consignments.Update(mapper.Map(consignment));
     this.uow.Commit();
 }
Пример #12
0
 public ConsignmentBusinessModel GetConsignmentById(int id)
 {
     var mapper = new ConsignmentMapper();
     var consignment = this.uow.Consignments.GetById(id);
     return mapper.Map(consignment);
 }