Ejemplo n.º 1
0
        public HttpResponseMessage DeleteCurrentStates(CurrentStateModel aCurrentStateModel)
        {
            IUnitOfWork             uWork = new UnitOfWork();
            ICurrentStateRepository repo  = new CurrentStateRepository(uWork);
            ICurrentStateService    currentStateService = new CurrentStateService(repo);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = currentStateService.DeleteCurrentState(aCurrentStateModel);
                    if (result != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                    else
                    {
                        string message = "Not deleted successfully";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetCurrentStates(BaseViewModel model)
        {
            IUnitOfWork             uWork = new UnitOfWork();
            ICurrentStateRepository repo  = new CurrentStateRepository(uWork);
            ICurrentStateService    currentStateService = new CurrentStateService(repo);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var CurrentStateList = currentStateService.GetAllCurrentStateList(model);
                    if (CurrentStateList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, CurrentStateList));
                    }
                    else
                    {
                        string message = "Error in getting Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
            }
        }