Esempio n. 1
0
 public BaseResponse <bool> Create(CommonValueCreateModel model)
 {
     try
     {
         var entity = _mapper.Map <CommonValueCreateModel, CommonValues>(model);
         entity.UniqueId = UniqueIDHelper.GenarateRandomString(12);
         _commonContext.CommonValues.Add(entity);
         _commonContext.SaveChanges();
         return(BaseResponse <bool> .Success(true));
     }
     catch (Exception ex)
     {
         return(BaseResponse <bool> .InternalServerError(ex));
     }
 }
Esempio n. 2
0
        public async Task <object> CreateNewCommonValues(CommonValueCreateModel model)
        {
            try
            {
                var req       = new BaseRequest <CommonValueCreateModel>(model);
                var apiResult = await _aPIExcute.PostData <object, CommonValueCreateModel>(commonValueUrl, HttpMethodEnum.POST, req, Token);

                return(apiResult.IsSuccessStatusCode);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public IActionResult CreateCommonValue([FromBody] CommonValueCreateModel model)
        {
            try
            {
                var flag = _commonValueService.CreateNewCommonValues(model);
                if (flag.Succeeded)
                {
                    return(Ok(flag));
                }

                return(BadRequest(flag.Errors[0].Description));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.StackTrace.ToString()));
            }
        }
Esempio n. 4
0
        public ApiActionResult CreateNewCommonValues(CommonValueCreateModel model)
        {
            try
            {
                CommonValues obj = new CommonValues();
                obj          = _mapper.Map <CommonValueCreateModel, CommonValues>(model);
                obj.UniqueId = UniqueIDHelper.GenerateRandomString(12);
                _dbConfigContext.CommonValues.Add(obj);
                var flag = _dbConfigContext.SaveChanges();

                if (flag != 0)
                {
                    return(ApiActionResult.Success());
                }
                return(ApiActionResult.Failed("Created Failed"));
            }
            catch (Exception ex)
            {
                return(ApiActionResult.Failed(ex.Message));
            }
        }
        public IActionResult Create([FromBody] CommonValueCreateModel model)
        {
            var result = _commonValueService.Create(model);

            return(Ok(result));
        }