Example #1
0
        public SaveResult Add(PeriodModel entity)
        {
            try
            {
                ObjectParameter param1 = new ObjectParameter("periodId", entity.PeriodId);

                if (IsReadyToAdd())
                {
                    var result = _context.proc_Period_Insert(param1, entity.YearFrom,
                                                             entity.YearTo);
                    return(new SaveResult
                    {
                        Id = (int)param1.Value,
                        Message = "Period was created and ready to configured.",
                        Status = "OK"
                    });
                }
                else
                {
                    throw new Exception("The transaction hasn't complete at this moment.");
                }
            }
            catch (Exception ex)
            {
                return(new SaveResult
                {
                    Id = 0,
                    Message = "Error on Period Add method. " + ex.InnerException != null ? ex.InnerException.Message : ex.Message,
                    Status = "ERROR"
                });
            }
        }