Ejemplo n.º 1
0
        public void Update(TMSOtSettingViewModel Vm)
        {
            var data = _mapper.Map <TMSOtSettingViewModel, TMSOtSetting>(Vm);

            _tMSOtSettingRepository.Update(data);
            SaveChanges();
        }
Ejemplo n.º 2
0
        public IActionResult Update([FromBody] TMSOtSettingViewModel Vm)
        {
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(new GenericResult(false, allErrors)));
            }
            else
            {
                try
                {
                    if (Vm.StartDate == null)
                    {
                        Vm.StartDate = new DateTime(0001, 01, 01, 00, 00, 00);
                    }

                    if (Vm.EndDate == null)
                    {
                        Vm.EndDate = new DateTime(0001, 01, 01, 00, 00, 00);
                    }

                    _tmsOtSettingService.Update(Vm);

                    return(new OkObjectResult(new GenericResult(true, "Update Success")));
                }
                catch (Exception ex)
                {
                    return(new OkObjectResult(new GenericResult(false, ex.Message)));
                }
            }
        }