示例#1
0
        public Result Create(TritCreateModel tritCreateModel)
        {
            var result = new Result();

            try
            {
                var db_trit = _tritRepository.GetAll().OrderByDescending(p => p.trit_id).FirstOrDefault();
                if (db_trit == null)
                {
                    tritCreateModel.trit_id = 1;
                }
                else
                {
                    tritCreateModel.trit_id = db_trit.trit_id + 1;
                }

                var trit = _mapper.Map <Trit>(tritCreateModel);
                _tritRepository.Add(trit);
                _tritRepository.Save();

                result.Message = Keywords.CreateInfo;
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = Keywords.CreateError;
                throw ex;
            }
            return(result);
        }
示例#2
0
        public IActionResult SendTritToDB(string user_id, string trit)
        {
            TritCreateModel tritCreateModel = new TritCreateModel
            {
                trit_text    = trit,
                trit_time    = DateTime.Now,
                trit_user_id = user_id
            };

            var result = _tritEngine.Create(tritCreateModel);


            return(Json(result));
        }