// GET: Cluster Group Delete
        public ActionResult Delete(ClusterGroup cluster)
        {
            ClusterGroup removeCluster = _clusterGroupSvc.Get(cluster.Id);
            _clusterGroupSvc.Remove(removeCluster);

            return View("List", _clusterGroupSvc.GetList().Select(CreateViewModel));
        }
        public ActionResult Create(ClusterGroup clusterGroup)
        {
            if (ModelState.IsValid)
            {
                bool clustedExists = _clusterGroupSvc.GetList().Any(t => t.Name.Equals(clusterGroup.Name, StringComparison.CurrentCultureIgnoreCase));

                if (!clustedExists)
                {

                    if (clusterGroup.Id == 0)
                        _clusterGroupSvc.Create(clusterGroup);
                    else
                        _clusterGroupSvc.Update(clusterGroup);

                    return View("List", _clusterGroupSvc.GetList().Select(CreateViewModel));
                }
                else
                {
                    ModelState.AddModelError("Name", string.Format("The name '{0}' is already in use.", clusterGroup.Name));
                }
            }

            ViewBag.ClusterGroups = _clusterGroupSvc.GetList();

            return View(clusterGroup);
        }
Ejemplo n.º 3
0
        public void Remove(ClusterGroup clusterGroup)
        {
            if (clusterGroup == null) throw new ArgumentNullException("cluster not passed to be deleted");
            if (String.IsNullOrWhiteSpace(clusterGroup.Name)) throw new ArgumentNullException("cluster name for cluster to be deleted can not be null");

            _svc.RemoveClusterGroup(clusterGroup);
        }
 private static ClusterGroupViewModel CreateViewModel(ClusterGroup clusterGroup)
 {
     return new ClusterGroupViewModel
     {
         Id = clusterGroup.Id,
         Name = clusterGroup.Name,
         Description = clusterGroup.Description
     };
 }
Ejemplo n.º 5
0
        public ClusterGroup Update(ClusterGroup clusterGroup)
        {
            if (_svc.Clusters.Any(d => d.Name == clusterGroup.Name))
                throw new ClusterGroupAlreadyExistsException();

            var result = _svc.UpdateClusterGroup(clusterGroup);

            return result;
        }
Ejemplo n.º 6
0
        public ClusterGroup UpdateClusterGroup(ClusterGroup updatedCluster)
        {
            var result = context.ClusterGroups.Find(updatedCluster.Id);

            if (result == null)
                throw new ClusterGroupNotFoundException();

            result.Name = updatedCluster.Name;
            result.Description = updatedCluster.Description;

            context.SaveChanges();

            return result;
        }
Ejemplo n.º 7
0
        public void RemoveClusterGroup(ClusterGroup cluster)
        {
            // attach the cluster to delete to the context, if needed. Otherwise the remove/delete won't work
            var cluster2Del = context.ClusterGroups.Local.FirstOrDefault(cc => cc.Id == cluster.Id);
            if (cluster2Del == null)
                context.ClusterGroups.Attach(cluster);

            context.ClusterGroups.Remove(cluster);
            context.SaveChanges();
        }
Ejemplo n.º 8
0
 public void AddClusterGroup(ClusterGroup newCluster)
 {
     context.ClusterGroups.Add(newCluster);
     context.SaveChanges();
 }
 // GET: ClusterGroup Create
 public ActionResult Create()
 {
     ClusterGroup newClusterGroup = new ClusterGroup();
     return View(newClusterGroup);
 }