Beispiel #1
0
        public void AddLob_WithNullLob_ShouldThrowException()
        {
            LobListModel lobModel = null;

            Func <object> addLob = () => this.service.AddLob(lobModel);

            var exception = Assert.ThrowsException <ArgumentException>(addLob);

            Assert.AreEqual(ValidationConstants.LobDefinedMessage, exception.Message);
        }
Beispiel #2
0
        public void AddLob_WithProperLob_ShouldAddCorrectly()
        {
            var lobModel = new LobListModel()
            {
                IdLob         = 5,
                Lob           = lobName,
                MmcpLob       = lobMmcpLob,
                MmcpSegment   = "MmcpSegment",
                ProductLine1  = "ProductLine1",
                ProductLine2  = "ProductLine2",
                ProductLine3  = "ProductLine3",
                SpphIdProduct = 1234
            };

            this.service.AddLob(lobModel);

            Assert.AreEqual(1, this.db.TblLob.Count());
            Assert.AreEqual(lobName, lobModel.Lob);
            Assert.AreEqual(lobMmcpLob, lobModel.MmcpLob);
        }
Beispiel #3
0
        public int UpdateLob(LobListModel model)
        {
            var lob = this.db
                      .TblLob
                      .Where(i => i.IdLob == model.IdLob)
                      .FirstOrDefault();

            lob.Lob           = model.Lob;
            lob.MmcpLob       = model.MmcpLob;
            lob.MmcpSegment   = model.MmcpSegment;
            lob.ProductLine1  = model.ProductLine1;
            lob.ProductLine2  = model.ProductLine2;
            lob.ProductLine3  = model.ProductLine3;
            lob.SpphIdProduct = model.SpphIdProduct;

            this.db.TblLob.Update(lob);
            this.db.SaveChanges();

            return(lob.IdLob);
        }
Beispiel #4
0
        public int AddLob(LobListModel model)
        {
            if (model == null)
            {
                throw new ArgumentException(ValidationConstants.LobDefinedMessage);
            }

            var lob = new tbl_Lob()
            {
                Lob           = model.Lob,
                MmcpLob       = model.MmcpLob,
                MmcpSegment   = model.MmcpSegment,
                ProductLine1  = model.ProductLine1,
                ProductLine2  = model.ProductLine2,
                ProductLine3  = model.ProductLine3,
                SpphIdProduct = model.SpphIdProduct
            };

            this.db.TblLob.Add(lob);
            this.db.SaveChanges();

            return(lob.IdLob);
        }