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));
            }
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddResponseCompression(options =>
            {
                options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[]
                {
                    MediaTypeNames.Application.Octet,
                    WasmMediaTypeNames.Application.Wasm,
                });
            });

            CurrentStateService.Initialize();
        }