Example #1
0
        public void UpdateByIdTest()
        {
            var response = _controller.GetById((int)_primaryKeyPool[2]);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkNegotiatedContentResult <OccupationRatingsModel>));
            OkNegotiatedContentResult <OccupationRatingsModel> result = (OkNegotiatedContentResult <OccupationRatingsModel>)response;

            Assert.IsNotNull(result.Content);
            Assert.IsInstanceOfType(result.Content, typeof(OccupationRatingsModel));
            OccupationRatingsModel content = (OccupationRatingsModel)result.Content;

            Assert.AreEqual(content.Id, _primaryKeyPool[2]);

            string  originalName   = content.Name;
            decimal originalFactor = content.Factor;

            content.Name  += " [Name Update]";
            content.Factor = 33.33M;

            _controller.UpdateById(content);

            response = _controller.GetById((int)_primaryKeyPool[2]);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkNegotiatedContentResult <OccupationRatingsModel>));
            result = (OkNegotiatedContentResult <OccupationRatingsModel>)response;
            Assert.IsNotNull(result.Content);
            Assert.IsInstanceOfType(result.Content, typeof(OccupationRatingsModel));
            content = (OccupationRatingsModel)result.Content;

            Assert.AreEqual(content.Name, originalName + " [Name Update]");
            Assert.AreEqual(content.Factor, 33.33M);
        }
Example #2
0
        public IHttpActionResult UpdateById(OccupationRatingsModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _occupationRatingsService.UpdateById(model);

            return(Ok(true));
        }
Example #3
0
        public IHttpActionResult Insert([FromBody] OccupationRatingsModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = _occupationRatingsService.Insert(model);

            return(Ok(result));
        }
Example #4
0
        public void GetByIdTest()
        {
            var response = _controller.GetById((int)_primaryKeyPool[1]);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkNegotiatedContentResult <OccupationRatingsModel>));
            OkNegotiatedContentResult <OccupationRatingsModel> result = (OkNegotiatedContentResult <OccupationRatingsModel>)response;

            Assert.IsNotNull(result.Content);
            Assert.IsInstanceOfType(result.Content, typeof(OccupationRatingsModel));
            OccupationRatingsModel content = (OccupationRatingsModel)result.Content;

            Assert.AreEqual(content.Id, _primaryKeyPool[1]);
        }
Example #5
0
        public void InsertTest()
        {
            OkNegotiatedContentResult <decimal?> pk4 = (OkNegotiatedContentResult <decimal?>)_controller.Insert(new OccupationRatingsModel()
            {
                Name   = "Red Collar [TEST]",
                Factor = 1.45M
            });

            _primaryKeyPool.Add(pk4.Content);

            var response = _controller.GetById((int)_primaryKeyPool[4]);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(OkNegotiatedContentResult <OccupationRatingsModel>));
            OkNegotiatedContentResult <OccupationRatingsModel> result = (OkNegotiatedContentResult <OccupationRatingsModel>)response;

            Assert.IsNotNull(result.Content);
            Assert.IsInstanceOfType(result.Content, typeof(OccupationRatingsModel));
            OccupationRatingsModel content = (OccupationRatingsModel)result.Content;

            Assert.AreEqual(content.Id, _primaryKeyPool[4]);
        }
        public decimal?Insert(OccupationRatingsModel model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.Name))
                {
                    throw new ApplicationException("Occupation ratings name cannot be an empty string.");
                }

                return(_OccupationRatingsRepository.Insert(model));
            }
            catch (Exception ex)
            {
                while (ex.Message.IndexOf("See the inner exception for details.") > 0)
                {
                    ex = ex.InnerException;
                }

                _logger.LogError(ex.Message);

                throw ex;
            }
        }
        public void UpdateById(OccupationRatingsModel model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.Name))
                {
                    throw new ApplicationException($"Occupation ratings name cannot be an empty string. Occupational Rating Id was {model.Id}.");
                }

                _OccupationRatingsRepository.UpdateById(model);
            }
            catch (Exception ex)
            {
                while (ex.Message.IndexOf("See the inner exception for details.") > 0)
                {
                    ex = ex.InnerException;
                }

                _logger.LogError(ex.Message);

                throw ex;
            }
        }
 public void UpdateById(OccupationRatingsModel model)
 {
     _context.spOccupationRatings_UpdateById(model.Id, model.Name, model.Factor);
 }
 public decimal?Insert(OccupationRatingsModel model)
 {
     return(_context.spOccupationRatings_Insert(model.Name, model.Factor).FirstOrDefault());
 }