Esempio n. 1
0
        public IActionResult PutFieldGroups(string slug, [FromBody] FieldGroupViewModel vmdl)
        {
            if (slug != vmdl.Slug)
            {
                return(BadRequest());
            }

            try
            {
                var fg = _bl.GetFieldGroup(vmdl.Slug);
                _bl.UpdateFieldGroup(fg);
                var f = fg.Fields.ToList();
                f.ForEach(i => _bl.DeleteField(i));
                fg.Fields.Clear();
                _bl.SaveChanges();
                vmdl.ApplyChanges(fg, _bl);
                vmdl.Refresh(fg);

                var meta = _bl.GetDeviceMeta()
                           .Where(i => i.FieldGroupSlug.Equals(slug))
                           .ToList();
                meta.ForEach(i => i.FieldGroupSlug = vmdl.Slug);

                _bl.SaveChanges();
                _log.LogInformation("FieldGroup '{0}' updated by '{1}'", vmdl.Name, User.Identity.Name);

                vmdl.Refresh(fg);
                return(Ok(vmdl));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_bl.FieldGroupExists(vmdl.Slug))
                {
                    _log.LogWarning("Not Found: FieldGroup '{0}' not found", slug);
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Esempio n. 2
0
        public void bl_should_return_if_fieldGroup_exists()
        {
            var obj = _bl.FieldGroupExists("prozessoren");

            Assert.True(obj);
        }