public IActionResult Post([FromBody] Call call)
 {
     using (var scope = new TransactionScope())
     {
         _callRepository.InsertCall(call);
         scope.Complete();
         return(CreatedAtAction(nameof(Get), new { id = call.Id }, call));
     }
 }
        public void Save(JObject obj)
        {
            string  type = obj.Properties().ElementAt(0).Name;
            JObject data = (JObject)obj[type];

            Call c = data.ToObject <Call>();

            Call call = callRepository.GetCallById(c.Id);

            if (call == null)
            {
                callRepository.InsertCall(c);
            }
        }
Example #3
0
        public async Task <CommandResult <bool> > Handle(CreateCallCommand command, CancellationToken cancellationToken)
        {
            var validation = _validator.Validate(command);

            if (!validation.IsValid)
            {
                _logger.Error("Create Call Command produced errors on validation {Errors}", validation.ToString());
                return(new CommandResult <bool>(result: false, type: CommandResultTypeEnum.InvalidInput));
            }
            var rowsAffected = await _callRepository.InsertCall(command.Call);

            if (rowsAffected == 0)
            {
                return(new CommandResult <bool>(result: false, type: CommandResultTypeEnum.UnprocessableEntity));
            }
            return(new CommandResult <bool>(result: true, type: CommandResultTypeEnum.Success));
        }