Exemplo n.º 1
0
        public async Task <IActionResult> CreateSetting([FromBody] CreateSettingResource resource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var input = _mapper.Map <CreateSettingResource, Setting>(resource);
                input.AddedBy = _admin.Fullname;
                var setting = await _settingService.CreateSetting(input);

                return(Ok(new { message = "Parametr yaradıldı" }));
            }
            catch (HttpException e)
            {
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult saveSetting(Setting settingModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (settingModel.Id != 0)
                {
                    settingService.UpdateSetting(settingModel);
                }
                else
                {
                    settingService.CreateSetting(settingModel);
                }

                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }