public TagViewModel(Tag tag)
 {
     Id = tag.Id;
     Name = tag.Name;
     Description = tag.Description;
     PageCount = tag.Pages.Count;
 }
        public long Update(Tag model)
        {
            using (var context = new OpenMuseumContext())
            {
                context.Entry(model).State = EntityState.Modified;
                context.SaveChanges();

                return model.Id;
            }
        }
        public long Add(Tag model)
        {
            using (var context = new OpenMuseumContext())
            {
                var result = context.Tags.Add(model);
                context.Entry(result).State = EntityState.Added;
                context.SaveChanges();

                return result.Id;
            }
        }
        public ActionResult Add(Tag model)
        {
            try
            {
                var tagsRepository = new TagsRepository();

                tagsRepository.Add(model);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public TagAPIViewModel(Tag tag)
 {
     Id = tag.Id;
     Name = tag.Name;
 }
        public ActionResult Edit(Tag model)
        {
            try
            {
                var tagsRepository = new TagsRepository();

                tagsRepository.Update(model);

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                return View();
            }
        }