Beispiel #1
0
        public void Update(TMSEventContractViewModel Vm)
        {
            var data = _mapper.Map <TMSEventContractViewModel, TMSEventContract>(Vm);

            if (Vm.Id >= 1)
            {
                _tMSEventContractRepository.Update(data);
            }
            else
            {
                _tMSEventContractRepository.Add(data);
            }

            SaveChanges();
        }
Beispiel #2
0
        public IActionResult Update([FromBody] TMSEventContractViewModel Vm)
        {
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(new GenericResult(false, allErrors)));
            }
            else
            {
                try
                {
                    _tmsEventContractService.Update(Vm);

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