Example #1
0
        public IActionResult Create([FromBody] InvestigationDispositions newmodel)
        {
            if (ModelState.IsValid)
            {
                _context.InvestigationDispositions.Add(newmodel);
                ReturnData ret;
                ret = _context.SaveData();

                if (ret.Message == "Success")
                {
                    return(CreatedAtRoute("GetInvestigationDispositions", new { id = newmodel.InvestigationDispositionsID }, newmodel));
                }

                return(NotFound(ret));
            }
            else
            {
                return(BadRequest());
            }
        }
Example #2
0
        public IActionResult UpdateEntry([FromBody] InvestigationDispositions objupd)
        {
            var targetObject = _context.InvestigationDispositions.FirstOrDefault(t => t.InvestigationDispositionsID == objupd.InvestigationDispositionsID);

            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));
        }
Example #3
0
        public void InvestigationDispositions()
        {
            IQueryable <InvestigationDispositions> InvestigationDispositionsInvestigationDispositions = Enumerable.Empty <InvestigationDispositions>().AsQueryable();
            InvestigationDispositions ct = new InvestigationDispositions {
                InvestigationDispositionsID = 1, DispositionDescription = "Test InvestigationDispositions"
            };

            Mock <IInvestigationDispositionsRepository> InvestigationDispositionsService = new Mock <IInvestigationDispositionsRepository>();

            object obj = new object();

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

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

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

                InvestigationDispositionsService.VerifyAll();

                InvestigationDispositionsObject.Dispose();
            }
            finally
            {
                InvestigationDispositionsService = null;
            }
        }
        public IActionResult Update([FromBody] InvestigationDispositions editentry)
        {
            var result = _repository.Update(editentry, editentry.InvestigationDispositionsID);

            return(Helper.CheckResult(result));
        }
        public IActionResult Create([FromBody] InvestigationDispositions newentry)
        {
            var result = _repository.Add(newentry);

            return(Helper.CheckResult(result));
        }