Example #1
0
        public IHttpActionResult AddCategory([FromBody] APIEditedCategoryModel editedCategoryModel)
        {
            object jsonObject;

            if (!ModelState.IsValid)
            {
                jsonObject = new { status = 500 };
                return(Json(jsonObject));
            }

            CategoryDTO categoryDTO     = dataMapper.MapEditedCategoryModelToDTO(editedCategoryModel);
            bool        addSuccessfully = categoryService.Add(categoryDTO);

            if (!addSuccessfully)
            {
                jsonObject = new { status = 500 };
            }
            else
            {
                APICategoryModel categoryModel = dataMapper.MapCategoryDTOToModel(categoryDTO);

                jsonObject = new {
                    status = 200,
                    data   = categoryModel
                };
            }

            return(Json(jsonObject));
        }
Example #2
0
        public JsonResult GetAPIServiceID()
        {
            DataControl.CurrentInfo _objcurrentInfo   = new DataControl.CurrentInfo();
            DataControl.BLMaster    _objBlmaster      = new DataControl.BLMaster();
            APICategoryModel        objDroAPICategory = new APICategoryModel();
            string APIId = "";

            try
            {
                IEnumerable <APIServiceModel> lstAPICategory = _objBlmaster.GetAPIServiceDetail(APIId);
                var apiCatlist = (from cat in lstAPICategory.AsEnumerable()
                                  select new APIServiceModel()
                {
                    API_ID = cat.API_ID.ToString(),
                    ServiceId = cat.ServiceId.ToString()
                }).ToList <APIServiceModel>();
                return(Json(apiCatlist));
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dicContext = new Dictionary <string, string>();
                DataControl.Impl.ExceptionHandler.WriteLog(ex, dicContext);
                return(Json("Sorry an error occured. Please try again later."));
            }
        }