Exemplo n.º 1
0
        public async Task <ActionResult <Receitas> > Post(Receitas 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 tagRec = new TagReceita()
                    {
                        Receitas = obj,
                        Tags     = tag
                    };
                    var tagExist = _unit.Tags.Get(x => x.Tag == item.Title);
                    if (tagExist.Count == 0)
                    {
                        _unit.Tags.Insert(tag);
                        _unit.TagProj.Insert(tagRec);
                    }
                }
                _unit.Receitas.Insert(obj);
                await _unit.CommitAssync();

                return(Ok(obj));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 public ActionResult tagReceita([FromQuery] TagReceita t)
 {
     _context.TagReceita.Add(t);
     _context.SaveChanges();
     return(Redirect("/Home/Editor/" + t.Receitaid));
 }