Beispiel #1
0
        public HttpResponseMessage DeleteBusinessCategoryDetails(BusinessCategoryDetailsModel model)
        {
            IUnitOfWork uWork = new UnitOfWork();
            IBusinessCategoryDetailsRepository businessCategoryDetails        = new BusinessCategoryDetailsRepository(uWork);
            IBusinessCategoryDetailsService    businessCategoryDetailsService = new BusinessCategoryDetailsService(businessCategoryDetails);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = businessCategoryDetailsService.DeleteBusinessCategoryDetails(model);
                    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));
            }
        }
Beispiel #2
0
        public HttpResponseMessage GetBusinessCategoryDetailsModels(BusinessCategoryDetailsModel model)
        {
            IUnitOfWork uWork = new UnitOfWork();
            IBusinessCategoryDetailsRepository businessCategoryDetails        = new BusinessCategoryDetailsRepository(uWork);
            IBusinessCategoryDetailsService    businessCategoryDetailsService = new BusinessCategoryDetailsService(businessCategoryDetails);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var businessCategoryDetailsList = businessCategoryDetailsService.GetAllBusinessCategoryDetailsList(model);
                    if (businessCategoryDetailsList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, businessCategoryDetailsList));
                    }
                    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));
            }
        }