Ejemplo n.º 1
0
        public IActionResult Get(string tableID = "", bool list = false)
        {
            List <Release> all = js.All <Release>();
            List <Release> filterd;
            List <Release> output;

            if (!string.IsNullOrWhiteSpace(tableID))
            {
                Table    t = js.Single <Table>(tableID);
                RDSystem s = js.Single <RDSystem>(t.SystemID);
                filterd = js.All <Release>().Where(r => r.SystemID == s.ID).ToList();
            }
            else
            {
                filterd = all;
            }

            if (list)
            {
                output = new List <Release>();
                filterd.ForEach(c => output.Add(new Release()
                {
                    Name = c.Name, Active = c.Active, ID = c.ID, SystemID = c.SystemID
                }));
            }
            else
            {
                output = filterd;
            }


            return(StatusCode(200, output));
        }
Ejemplo n.º 2
0
        public void OnGet(string focus, string action)
        {
            ExistingSystems = client.GetListOf <RDSystem>();

            if (action == "A")
            {
                FocusedItem = new RDSystem()
                {
                    ID = "NEW"
                };
                client.ItemInFocus = true;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(focus))
                {
                    try
                    {
                        FocusedItem        = ExistingSystems.Single(i => i.ID.Equals(focus.Trim()));
                        client.ItemInFocus = true;
                    }
                    catch (Exception e)
                    {
                        Message            = "Something went wrong: " + e.Message;
                        client.ItemInFocus = false;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public IActionResult Post([FromBody] dynamic value)
        {
            string   postedData = value.ToString();
            RDSystem sysData    = JsonConvert.DeserializeObject <RDSystem>(postedData);

            sysData.ID = Guid.NewGuid().ToString();
            js.Add(sysData);
            js.SaveChanges();
            return(StatusCode(201, sysData));
        }
Ejemplo n.º 4
0
        public IActionResult Put(string id, [FromBody] dynamic value)
        {
            RDSystem curData = js.Single <RDSystem>(id);

            string   postedData = value.ToString();
            RDSystem newData    = JsonConvert.DeserializeObject <RDSystem>(postedData);

            newData.ID = curData.ID;

            js.Add(new Archive(curData, Reason.Update));
            js.Remove(curData);
            if (newData.Active)
            {
                js.Add(newData);
            }
            js.SaveChanges();

            return(StatusCode(202));
        }
Ejemplo n.º 5
0
 public void OnPost(RDSystem FocusedItem)
 {
     if (FocusedItem.ID != "NEW")
     {
         RDSystem cItem = client.GetItemByID <RDSystem>(FocusedItem.ID);
         if (!(FocusedItem.Active == cItem.Active & FocusedItem.Name == cItem.Name & FocusedItem.ID == cItem.ID))
         {
             Message = client.PutItemByID <RDSystem>(FocusedItem.ID, FocusedItem).StatusCode.ToString();
         }
         else
         {
             Message = "No Action Taken.";
         }
     }
     else
     {
         Message = client.PostItem <RDSystem>(FocusedItem).StatusCode.ToString();
     }
     OnGet("", "");
 }
Ejemplo n.º 6
0
        public IActionResult Get(string tableID = "", bool ignoreChanges = false, bool list = false)
        {
            List <ChangeSet> allchanges;
            List <ChangeSet> filterdList;
            List <ChangeSet> output;

            allchanges = js.All <ChangeSet>();

            if (!string.IsNullOrWhiteSpace(tableID))
            {
                if (ignoreChanges)
                {
                    Table            t   = js.Single <Table>(tableID);
                    RDSystem         s   = js.Single <RDSystem>(t.SystemID);
                    List <Release>   rel = js.All <Release>().Where(r => r.SystemID == s.ID).ToList();
                    HashSet <string> uniqueReleaseIDs = new HashSet <string>();
                    rel.ForEach(r => uniqueReleaseIDs.Add(r.ID));
                    filterdList = new List <ChangeSet>();
                    foreach (ChangeSet c in allchanges)
                    {
                        if (uniqueReleaseIDs.Contains(c.ReleaseID))
                        {
                            filterdList.Add(c);
                        }
                    }
                }
                else
                {
                    List <Change>    changes     = js.All <Change>().Where(c => c.TableID == tableID).ToList();
                    HashSet <string> uniqueCSIds = new HashSet <string>();
                    changes.ForEach(c => uniqueCSIds.Add(c.ChangeSetID));
                    filterdList = new List <ChangeSet>();
                    foreach (ChangeSet c in allchanges)
                    {
                        if (uniqueCSIds.Contains(c.ID))
                        {
                            filterdList.Add(c);
                        }
                    }
                }
            }
            else
            {
                filterdList = allchanges;
            }

            if (list)
            {
                output = new List <ChangeSet>();
                filterdList.ForEach(c => output.Add(new ChangeSet()
                {
                    Name = c.Name, Active = c.Active, ID = c.ID, ReleaseID = c.ReleaseID
                }));
            }
            else
            {
                output = filterdList;
                foreach (ChangeSet cs in output)
                {
                    cs.Changes = js.All <Change>().Where(c => c.ChangeSetID == cs.ID).ToList();
                }
            }

            return(StatusCode(200, output));
        }