示例#1
0
        public async Task <ActionResult <Perguntas> > Post(Perguntas obj)
        {
            try
            {
                obj.Date = DateTime.Now;
                var tagList = new List <Tags>();
                foreach (var item in obj.Tags)
                {
                    var tag = new Tags()
                    {
                        Tag = item.Title
                    };
                    var tagPerg = new TagPergunta()
                    {
                        Perguntas = obj,
                        Tags      = tag
                    };
                    var tagExist = _unit.Tag.Get(x => x.Tag == item.Title);
                    if (tagExist.Count == 0)
                    {
                        _unit.Tag.Insert(tag);
                        _unit.TagPerg.Insert(tagPerg);
                    }
                }
                _unit.Perguntas.Insert(obj);
                await _unit.CommitAssync();

                return(Ok(obj));
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public async Task <ActionResult <Respostas> > Post(Respostas obj)
        {
            try
            {
                obj.Data = DateTime.Now;
                _unit.Respostas.Insert(obj);
                await _unit.CommitAssync();

                return(Ok(obj));
            }
            catch (Exception)
            {
                throw;
            }
        }