// POST api/<controller>
        public IHttpActionResult Post(object obj)
        {
            long retId;

            try
            {
                retId = _transactionTypeService.Add(obj);

                if (retId == 0)
                {
                    Log.Info($"{typeof(TransactionTypesController).FullName}||{UserEnvironment}||Add record not successful, Transaction Type Code is duplicate.");
                    return(Content(HttpStatusCode.Forbidden, "Transaction Type Code is Duplicate"));
                }
                Log.Info($"{typeof(TransactionTypesController).FullName}||{UserEnvironment}||Add record successful.");
            }
            catch (Exception e)
            {
                Log.Error(typeof(TransactionTypesController).FullName, e);

                return(Content(HttpStatusCode.NotAcceptable, e.Message));
            }

            var response = Request.CreateResponse(HttpStatusCode.Created);
            var test     = JsonConvert.SerializeObject(new
            {
                id      = retId,
                message = "Transaction Type added"
            });

            response.Content = new StringContent(test, Encoding.UTF8, "appliation/json");
            return(ResponseMessage(response));
        }
Exemple #2
0
        public async Task <TransactionTypeModel> Add([FromForm] string name, [FromForm] string extension, [FromForm] IFormFile file)
        {
            var res = await _transactionTypeService.Add(name, extension, file);

            return(_mapper.Map <TransactionTypeModel>(res));
        }