Example #1
0
        //if( !ModelState.IsValid )
        //    throw new HttpResponseException( HttpStatusCode.BadRequest );

        //var checkerBodegeroInDb = _context.CheckerBodegeros.SingleOrDefault( c => c.ID == id );

        //if( checkerBodegeroInDb == null )
        //    throw new HttpResponseException( HttpStatusCode.NotFound );

        //checkerBodegeroInDb.EmpID = checkerBodegero.EmpID;
        //checkerBodegeroInDb.Name = checkerBodegero.Name;
        //checkerBodegeroInDb.Designation = checkerBodegero.Designation;

        //_context.SaveChanges( );


        /// <summary>
        /// DELETE request
        /// Deletes the employee
        /// </summary>
        /// <param name="id">Identity</param>
        public void DeleteCheckerBodegero(int id)
        {
            //_modelValidation.ErrorNotFound( );

            var checkerBodegeroInDb = _retrieveEmployeeSingleOrDefault.GetEmployee(id, _context);

            //_validationException.RequestException(id/*, HttpStatusCode.NotFound*/ );
            if (checkerBodegeroInDb == null)
            {
                StatusCodeExceptionResponse.StatusCodeException(HttpStatusCode.NotFound);
            }

            _context.CheckerBodegeros.Remove(checkerBodegeroInDb);
            _context.SaveChanges( );
        }
Example #2
0
        /// <summary>
        /// PUT request
        /// Edit and updates the records of employee
        /// </summary>
        /// <param name="id">Identity</param>
        /// <param name="checkerBodegero">Object model</param>
        public void UpdateCheckerBodegero(int id, CheckerBodegero checkerBodegero)
        {
            //_modelValidation.ErrorBadRequest(  );

            var checkerBodegeroInDb = _retrieveEmployeeSingleOrDefault.GetEmployee(id, _context);

            //_validationException.RequestException( id/*, HttpStatusCode.NotFound*/ );
            if (checkerBodegeroInDb == null)
            {
                StatusCodeExceptionResponse.StatusCodeException(HttpStatusCode.NotFound);
            }

            checkerBodegeroInDb.EmpID       = checkerBodegero.EmpID;
            checkerBodegeroInDb.Name        = checkerBodegero.Name;
            checkerBodegeroInDb.Designation = checkerBodegero.Designation;

            _context.SaveChanges( );
        }