Exemplo n.º 1
0
        public IActionResult Create([FromBody] BWQStatusType newmodel)
        {
            if (ModelState.IsValid)
            {
                _context.BWQStatusType.Add(newmodel);
                _context.SaveChanges();

                return(CreatedAtRoute("GetBWQStatusType", new { id = newmodel.BWQStatusTypeID }, newmodel));
            }
            else
            {
                return(BadRequest());
            }
        }
Exemplo n.º 2
0
        public IActionResult UpdateEntry([FromBody] BWQStatusType objupd)
        {
            var targetObject = _context.BWQStatusType.FirstOrDefault(t => t.BWQStatusTypeID == objupd.BWQStatusTypeID);

            if (targetObject == null)
            {
                return(NotFound());
            }

            _context.Entry(targetObject).CurrentValues.SetValues(objupd);
            ReturnData ret;

            ret = _context.SaveData();

            if (ret.Message == "Success")
            {
                return(Ok());
            }

            return(NotFound(ret));
        }
Exemplo n.º 3
0
        public void StatusType()
        {
            ILogger <BWQStatusTypeController> _testlogger = null;

            using (var context = new AppDbContext(options, null))
            {
                var controller = new BWQStatusTypeController(context, _testlogger);
                // Get all
                var result = controller.Get();
                // Assert
                var okResult = Assert.IsAssignableFrom <IEnumerable <BWQStatusType> >(result);
                var pgcount  = okResult.ToList().Count;
                Assert.Equal(2, pgcount);
                // Get by ID
                var result1   = controller.Get(1);
                var okResult1 = Assert.IsAssignableFrom <BWQStatusType>(result1);
                //var thisresult1 = okResult1.FirstOrDefault();
                Assert.Equal("bwqstatus type 1", result1.BwqStatusTypeDescription);

                // test update
                var pg1 = new BWQStatusType {
                    BWQStatusTypeID = 1, BwqStatusTypeDescription = "bwqstatus type 1 upd"
                };
                controller.UpdateEntry(pg1);
                var result3 = controller.Get(1);
                //var thisresult3 = result3.FirstOrDefault();
                Assert.NotEqual("bwqstatus type 1", result3.BwqStatusTypeDescription);
                Assert.Equal("bwqstatus type 1 upd", result3.BwqStatusTypeDescription);

                // test delete
                var result4 = controller.Get(2);
                //var thisresult4 = result4.FirstOrDefault();
                Assert.Equal("bwqstatus type 2", result4.BwqStatusTypeDescription);

                IActionResult result5    = controller.Delete(2);
                var           viewResult = Assert.IsType <Microsoft.AspNetCore.Mvc.OkResult>(result5);
                var           result6    = controller.Get(2);
                Assert.Null(result6);
            }
        }
Exemplo n.º 4
0
        public void BWQStatusType()
        {
            IQueryable <BWQStatusType> BWQStatusTypeBWQStatusType = Enumerable.Empty <BWQStatusType>().AsQueryable();
            BWQStatusType ct = new BWQStatusType {
                BWQStatusTypeID = 1, BwqStatusTypeDescription = "Test BWQStatusType"
            };

            Mock <IBWQStatusTypeRepository> BWQStatusTypeService = new Mock <IBWQStatusTypeRepository>();

            object obj = new object();

            try
            {
                BWQStatusTypeService.Setup(x => x.GetAll()).Returns(BWQStatusTypeBWQStatusType);
                BWQStatusTypeService.Setup(x => x.Get(It.IsAny <int>())).Returns(ct);
                BWQStatusTypeService.Setup(x => x.Add(It.IsAny <BWQStatusType>())).Returns(ct);
                BWQStatusTypeService.Setup(x => x.Delete(It.IsAny <BWQStatusType>())).Verifiable();
                BWQStatusTypeService.Setup(x => x.Update(It.IsAny <BWQStatusType>(), It.IsAny <object>())).Returns(ct);

                var BWQStatusTypeObject = BWQStatusTypeService.Object;
                var p1 = BWQStatusTypeObject.GetAll();
                var p2 = BWQStatusTypeObject.Get(1);
                var p3 = BWQStatusTypeObject.Update(ct, obj);
                var p4 = BWQStatusTypeObject.Add(ct);
                BWQStatusTypeObject.Delete(ct);

                Assert.IsAssignableFrom <IQueryable <BWQStatusType> >(p1);
                Assert.IsAssignableFrom <BWQStatusType>(p2);
                Assert.Equal("Test BWQStatusType", p2.BwqStatusTypeDescription);
                Assert.Equal("Test BWQStatusType", p3.BwqStatusTypeDescription);

                BWQStatusTypeService.VerifyAll();

                BWQStatusTypeObject.Dispose();
            }
            finally
            {
                BWQStatusTypeService = null;
            }
        }
Exemplo n.º 5
0
        public IActionResult Update([FromBody] BWQStatusType editentry)
        {
            var result = _repository.Update(editentry, editentry.BWQStatusTypeID);

            return(Helper.CheckResult(result));
        }
Exemplo n.º 6
0
        public IActionResult Create([FromBody] BWQStatusType newentry)
        {
            var result = _repository.Add(newentry);

            return(Helper.CheckResult(result));
        }
Exemplo n.º 7
0
        internal void PopulateData()
        {
            using (var context = new AppDbContext(options, null))
            {
                if (context.Collection.Count() < 1)
                {
                    var p1 = new Collection {
                        CollectionID = 1, CollectionName = "collection type 1",
                    };
                    var p2 = new Collection {
                        CollectionID = 2, CollectionName = "collection type 2",
                    };
                    context.Collection.Add(p1);
                    context.Collection.Add(p2);

                    context.SaveChanges();
                }

                if (context.CollectionItem.Count() < 1)
                {
                    var p1 = new CollectionItem {
                        CollectionItemID = 1, CollectionID = 1, ItemText = "collectionitem type 1",
                    };
                    var p2 = new CollectionItem {
                        CollectionItemID = 2, CollectionID = 1, ItemText = "collectionitem type 2",
                    };
                    context.CollectionItem.Add(p1);
                    context.CollectionItem.Add(p2);

                    if (context.Collection.Count() < 1)
                    {
                        var p3 = new Collection {
                            CollectionID = 1, CollectionName = "collection type 1",
                        };
                    }

                    context.SaveChanges();
                }

                if (context.BWQStatusType.Count() < 1)
                {
                    var p1 = new BWQStatusType {
                        BWQStatusTypeID = 1, BwqStatusTypeDescription = "bwqstatus type 1",
                    };
                    var p2 = new BWQStatusType {
                        BWQStatusTypeID = 2, BwqStatusTypeDescription = "bwqstatus type 2",
                    };
                    context.BWQStatusType.Add(p1);
                    context.BWQStatusType.Add(p2);

                    context.SaveChanges();
                }

                if (context.BWQFieldSelect.Count() < 1)
                {
                    var p1 = new BWQFieldSelect {
                        BWQFieldSelectID = 1, FieldDisplayName = "fieldselect type 1",
                    };
                    var p2 = new BWQFieldSelect {
                        BWQFieldSelectID = 2, FieldDisplayName = "fieldselect type 2",
                    };
                    context.BWQFieldSelect.Add(p1);
                    context.BWQFieldSelect.Add(p2);

                    context.SaveChanges();
                }

                if (context.BWQDispositions.Count() < 1)
                {
                    var p1 = new BWQDispositions {
                        BWQDispositionsID = 1, BWQDispositionsDescription = "bwqdisposition type 1",
                    };
                    var p2 = new BWQDispositions {
                        BWQDispositionsID = 2, BWQDispositionsDescription = "bwqdisposition type 2",
                    };
                    context.BWQDispositions.Add(p1);
                    context.BWQDispositions.Add(p2);

                    context.SaveChanges();
                }

                if (context.BWQEntities.Count() < 1)
                {
                    var p1 = new BWQEntities {
                        BWQEntitiesID = 1, BWQID = 1, EntityName = "bwqentity type 1",
                    };
                    var p2 = new BWQEntities {
                        BWQEntitiesID = 2, BWQID = 1, EntityName = "bwqentity type 2",
                    };
                    context.BWQEntities.Add(p1);
                    context.BWQEntities.Add(p2);

                    if (context.BWQ.Count() < 1)
                    {
                        var p3 = new BWQ {
                            BWQID = 1, BatchName = "bwqbatch 1",
                        };
                    }
                    context.SaveChanges();
                }

                if (context.BWQ.Count() < 1)
                {
                    var p1 = new BWQ {
                        BWQID = 1, BatchName = "bwqbatch 1",
                    };
                    var p2 = new BWQ {
                        BWQID = 2, BatchName = "bwqbatch 2",
                    };
                    context.BWQ.Add(p1);
                    context.BWQ.Add(p2);

                    context.SaveChanges();
                }

                if (context.BWQInstructions.Count() < 1)
                {
                    var p1 = new BWQInstructions {
                        BWQInstructionsID = 1, BWQEntitiesID = 1, BWQDispositionsID = 1, BWQFieldSelectID = 1, Instructions = "Instructions 1"
                    };
                    var p2 = new BWQInstructions {
                        BWQInstructionsID = 2, BWQEntitiesID = 1, BWQDispositionsID = 1, BWQFieldSelectID = 1, Instructions = "Instructions 2"
                    };
                    context.BWQInstructions.Add(p1);
                    context.BWQInstructions.Add(p2);

                    if (context.BWQEntities.Count() < 1)
                    {
                        var p3 = new BWQEntities {
                            BWQEntitiesID = 1, BWQID = 1, EntityName = "bwqentity type 1",
                        };
                        context.BWQEntities.Add(p3);
                    }
                    if (context.BWQDispositions.Count() < 1)
                    {
                        var p4 = new BWQDispositions {
                            BWQDispositionsID = 1, BWQDispositionsDescription = "bwqdisposition type 1",
                        };
                        context.BWQDispositions.Add(p4);
                    }
                    if (context.BWQFieldSelect.Count() < 1)
                    {
                        var p5 = new BWQFieldSelect {
                            BWQFieldSelectID = 1, FieldDisplayName = "fieldselect type 1",
                        };
                        context.BWQFieldSelect.Add(p5);
                    }

                    context.SaveChanges();
                }
            }
        }