Beispiel #1
0
        public ActionResult CreateNewTag(string title)
        {
            Tag newTag = new Tag(title);

            using (var db = new ServerDb())
            {
            var old = db.Tags.Where(m => m.title == newTag.title)
                    .FirstOrDefault();

                // Save Existing
            if (old != null)
            {
                db.Tags.Remove(old);
                db.Tags.Add(newTag);
            }
                // Save New
            else
            {
                db.Tags.Add(newTag);

            }

            db.SaveChanges();
            }
            return PartialView(newTag);
        }
Beispiel #2
0
        public ActionResult GetTags()
        {
            using (var db = new ServerDb())
            {
                var result = db.Tags
                    .ToList();

                return PartialView(result);

            }
        }
Beispiel #3
0
        public List<MasterEntity> Servers()
        {
            using (var db = new ServerDb())
            {
                var result = db.Servers
                    .Include(m => m.services)
                    .Include("applications.dependencies")
                    .ToList();

                return result;
            }
        }
Beispiel #4
0
        public JsonResult Entities()
        {
            using (var db = new ServerDb())
            {
                var result = db.Servers
                    .Include(m => m.services)
                    .Include("applications.dependencies")
                    .ToList();

                return Json(result, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult Details(string id)
        {
            using (var db = new ServerDb())
            {
                var result = db.Servers
                    .Include(m => m.environment)
                    .Include(m => m.services)
                    .Include(m => m.iis)
                    .Include("iis.websites.applicationPools")

                    .Where(m => m.Id == id)
                    .FirstOrDefault();
                return View(result);
            }
        }
 public ActionResult Index()
 {
     using (var db = new ServerDb())
     {
         var result = db.Servers
             .Include(m => m.services)
             .Include(m => m.environment)
             .Include(m => m.owner)
             .Include("services.dependencies")
             .OrderByDescending(m => m.Id)
             .Skip(0)
             .Take(50)
             .ToList();
         return PartialView(result);
     }
 }
        public object Post([FromBody] MasterEntity content)
        {
            var json = this.Request.Content.ReadAsStringAsync().Result;
            Console.WriteLine(json);

            using (var db = new ServerDb())
            {
                // Check if the server already exists in the DB
                var old = db.Servers.Where(m => m.Id == content.Id)
                    .Include(m => m.environment)
                    .Include(m => m.iis)
                    .FirstOrDefault();

                // Save Existing Server
                if (old != null)
                {
                    db.Servers.Remove(old);

                    db.Servers.Add(content);

                    db.SaveChanges();
                }
                    // Save New Server
                else {
                    db.Servers.Add(content);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (System.Data.Entity.Validation.DbEntityValidationException e)
                    {
                        throw;
                    }
                }
            }

            return Request.CreateResponse(HttpStatusCode.OK, "OK");
        }