Exemplo n.º 1
0
        public IActionResult Put([FromBody] CashJournal entity)
        {
            IActionResult ret = null;

            try
            {
                if (entity != null)
                {
                    using (var db = new BTAContext())
                    {
                        db.Update(entity);
                        db.SaveChanges();
                        ret = StatusCode(StatusCodes.Status200OK, entity);
                    }
                }
                else
                {
                    ret = StatusCode(StatusCodes.Status400BadRequest, "Invalid data passed for cash journal update");
                }
            }
            catch (Exception ex)
            {
                ret = HandleException(ex, "Exception trying to update cash journal entry: " + entity.CashJournalId.ToString());
            }

            return(ret);
        }
        public IActionResult Put([FromBody] ContributionCategory entity)
        {
            var result = new ContributionCategoryActionResult(false, new List <string>(), null);

            try
            {
                if (entity != null)
                {
                    using (var db = new BTAContext())
                    {
                        db.Update(entity);
                        db.SaveChanges();
                        result.Success = true;
                        result.Data    = entity;
                        result.StatusMessages.Add("Successfully updated contribution category.");
                    }
                }
                else
                {
                    result.Success = false;
                    result.Data    = null;
                    result.StatusMessages.Add("Invalid data passed to contribution category update.");
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("Exception trying to update a contribution category entry.");
                Logger.LogError(ex.ToString());
                result.Success = false;
                result.Data    = null;
                result.StatusMessages.Add("Exception trying to update a contribution category entry.");
            }

            return(StatusCode(StatusCodes.Status200OK, result));
        }