Exemplo n.º 1
0
        public IHttpActionResult GetAllMerits()
        {
            try
            {
                List <MemberDeMeritViewModel> meritList = new List <MemberDeMeritViewModel>();
                IEnumerable <Merit>           merits    = new List <Merit>();
                merits = _common.GetAllMerits();

                foreach (Merit merit in merits)
                {
                    MemberDeMeritViewModel meritView = new MemberDeMeritViewModel();
                    meritView.meritId     = merit.ID;
                    meritView.code        = merit.Code;
                    meritView.description = merit.Description;
                    meritView.colorCode   = merit.ColorCodeId;
                    meritView.point       = 0;

                    meritList.Add(meritView);
                }

                var messageData  = new { code = Constant.SuccessMessageCode, message = Constant.MessageSuccess };
                var returnObject = new { merits = meritList, messageCode = messageData };
                return(Ok(returnObject));
            }
            catch (Exception ex)
            {
                string errorLogId   = _eventLog.WriteLogs(User.Identity.Name, ex, MethodBase.GetCurrentMethod().Name);
                var    messageData  = new { code = Constant.ErrorMessageCode, message = String.Format(Constant.MessageTaskmateError, errorLogId) };
                var    returnObject = new { messageCode = messageData };
                return(Ok(returnObject));
            }
        }