コード例 #1
0
        public async Task <ActionResult> PostSubCategory(SubCategoryDto subCategoryDto)
        {
            var subCategory = _mapper.Map <SubCategory>(subCategoryDto);
            await _repo.Add(subCategory);

            var subCategoryToReturn = _mapper.Map <SubCategoryDto>(subCategory);

            return(CreatedAtAction("GetSubCategory", new { id = subCategoryToReturn.Id }, subCategoryToReturn));
        }
コード例 #2
0
        public IHttpActionResult Add(TOURIS_TV_SUB_CATEGORY subCategoryView)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                TOURIS_TM_SUB_CATEGORY subCategory = new TOURIS_TM_SUB_CATEGORY();
                subCategory.CATEGORY_ID              = subCategoryView.CATEGORY_ID;
                subCategory.VILLAGE_ID               = subCategoryView.VILLAGE_ID;
                subCategory.SUB_CATEGORY_NAME        = subCategoryView.SUB_CATEGORY_NAME;
                subCategory.SUB_CATEGORY_DESCRIPTION = subCategoryView.SUB_CATEGORY_DESCRIPTION;
                subCategory.START_TIME               = subCategoryView.START_TIME;
                subCategory.END_TIME     = subCategoryView.END_TIME;
                subCategory.PHOTO_PATH   = subCategoryView.PHOTO_PATH;
                subCategory.ADDRESS      = subCategoryView.ADDRESS;
                subCategory.LATITUDE     = subCategoryView.LATITUDE;
                subCategory.LONGITUDE    = subCategoryView.LONGITUDE;
                subCategory.CREATED_BY   = subCategoryView.CREATED_BY;
                subCategory.CREATED_TIME = subCategoryView.CREATED_TIME;
                subCategory.ROW_STATUS   = eStat.fg.IsActive;

                rs = repo.Add(subCategory);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
コード例 #3
0
 public IActionResult Add(SubCategoryViewModel vm)
 {
     subCatrepo.Add(vm);
     return(RedirectToAction(nameof(Index)));
 }