Пример #1
0
        // GET: api/User
        public IEnumerable <User> Get()
        {
            List <User> returnUsers = new List <User>();

            using (var db = new EModelsContext())
            {
                var result = db.sharepoint_users.OrderByDescending(user => user.id).ToList();

                foreach (var eUser in result)
                {
                    User returnUser = new User();
                    returnUser.id           = eUser.id;
                    returnUser.name         = eUser.name;
                    returnUser.email        = eUser.email;
                    returnUser.phone        = eUser.phone;
                    returnUser.userCode     = eUser.user_code;
                    returnUser.permissionid = eUser.permissionid;
                    returnUser.permission   = eUser.sharepoint_permissions == null ? "None" : eUser.sharepoint_permissions.type;
                    returnUser.groupid      = eUser.groupid;
                    returnUser.group        = eUser.sharepoint_usergroups == null ? "None" : eUser.sharepoint_usergroups.name;

                    returnUsers.Add(returnUser);
                }
            }

            return(returnUsers);
        }
Пример #2
0
 // POST: api/Supplier
 public void Post([FromBody] Supplier data)
 {
     using (var db = new EModelsContext())
     {
         supplier supplier = new supplier {
             name = data.name
         };
         db.suppliers.Add(supplier);
         db.SaveChanges();
     }
 }
Пример #3
0
        // GET: api/Supplier/5
        public Supplier Get(int id)
        {
            Supplier returnSupplier = new Supplier();

            using (var db = new EModelsContext())
            {
                var eSupplier = db.suppliers.Where(sup => sup.id.Equals(id)).Single();
                returnSupplier.id   = eSupplier.id;
                returnSupplier.name = eSupplier.name;
            }
            return(returnSupplier);
        }
Пример #4
0
 // DELETE: api/AnalysisCode/5
 public void Delete(int id)
 {
     using (var db = new EModelsContext())
     {
         var eAnalysisCode = db.analysis_codes.Where(ac => ac.id.Equals(id)).SingleOrDefault();
         if (eAnalysisCode != null)
         {
             db.analysis_codes.Remove(eAnalysisCode);
             db.SaveChanges();
         }
     }
 }
Пример #5
0
 // PUT: api/AnalysisCode/5
 public void Put(int id, [FromBody] AnalysisCode data)
 {
     using (var db = new EModelsContext())
     {
         var eAnalysisCode = db.analysis_codes.Where(ac => ac.id.Equals(id)).SingleOrDefault();
         if (eAnalysisCode != null)
         {
             eAnalysisCode.code = data.code;
             db.SaveChanges();
         }
     }
 }
Пример #6
0
 // POST: api/AnalysisCode
 public void Post([FromBody] AnalysisCode data)
 {
     using (var db = new EModelsContext())
     {
         analysis_codes analysisCode = new analysis_codes
         {
             code = data.code
         };
         db.analysis_codes.Add(analysisCode);
         db.SaveChanges();
     }
 }
Пример #7
0
 // PUT: api/Supplier/5
 public void Put(int id, [FromBody] Supplier data)
 {
     using (var db = new EModelsContext())
     {
         var eSupplier = db.suppliers.Where(sup => sup.id.Equals(id)).SingleOrDefault();
         if (eSupplier != null)
         {
             eSupplier.name = data.name;
             db.SaveChanges();
         }
     }
 }
Пример #8
0
 // DELETE: api/Supplier/5
 public void Delete(int id)
 {
     using (var db = new EModelsContext())
     {
         var eSupplier = db.suppliers.Where(sup => sup.id.Equals(id)).SingleOrDefault();
         if (eSupplier != null)
         {
             db.suppliers.Remove(eSupplier);
             db.SaveChanges();
         }
     }
 }
Пример #9
0
        // GET: api/AutoComplete
        public IEnumerable <string> Get(string type)
        {
            List <string> items = new List <string>();

            using (var db = new EModelsContext())
            {
                if (type.Equals("descriptions"))
                {
                    var result = db.descriptions.ToList();
                    foreach (var eDescription in result)
                    {
                        items.Add(eDescription.description1);
                    }
                }
                else if (type.Equals("analysiscodes"))
                {
                    //array of strings of all analysis codes in the analysis_codes table
                    var result = db.analysis_codes.ToList();
                    foreach (var eAnalysisCode in result)
                    {
                        items.Add(eAnalysisCode.code);
                    }
                }
                else if (type.Equals("rooms"))
                {
                    //an array of strings of all rooms in the rooms table
                    var result = db.rooms.ToList();
                    foreach (var eRoom in result)
                    {
                        items.Add(eRoom.room1);
                    }
                }
                else if (type.Equals("permissions"))
                {
                    //an array of strings of all rooms in the rooms table
                    var result = db.sharepoint_permissions.ToList();
                    foreach (var ePermission in result)
                    {
                        items.Add(ePermission.type);
                    }
                }
                else if (type.Equals("groups"))
                {
                    //an array of strings of all rooms in the rooms table
                    var result = db.sharepoint_usergroups.ToList();
                    foreach (var eGroup in result)
                    {
                        items.Add(eGroup.name);
                    }
                }
            }
            return(items);
        }
Пример #10
0
 // DELETE: api/User/5
 public void Delete(int id)
 {
     using (var db = new EModelsContext())
     {
         var eUser = db.sharepoint_users.Where(user => user.id.Equals(id)).SingleOrDefault();
         if (eUser != null)
         {
             db.sharepoint_users.Remove(eUser);
             db.SaveChanges();
         }
     }
 }
Пример #11
0
        // GET: api/Miscellaneous/GL11223213
        public bool Get(string account)
        {
            using (var db = new EModelsContext())
            {
                var count = db.accounts.Where(acc => acc.number.Equals(account)).Count();
                if (count > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #12
0
        // GET: api/AnalysisCode/5
        public AnalysisCode Get(int id)
        {
            AnalysisCode returnAnalysisCode = new AnalysisCode();

            using (var db = new EModelsContext())
            {
                var eAnalysisCode = db.analysis_codes.Where(ac => ac.id.Equals(id)).Single();

                returnAnalysisCode.id   = eAnalysisCode.id;
                returnAnalysisCode.code = eAnalysisCode.code;
            }
            return(returnAnalysisCode);
        }
Пример #13
0
        // GET: api/Miscellaneous
        public IEnumerable <KeyValuePair <string, string> > Get()
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            using (var db = new EModelsContext())
            {
                var result = db.tooltips.ToList();

                foreach (var eTooltip in result)
                {
                    string field = eTooltip.field;
                    string data  = eTooltip.tooltip1;
                    dictionary.Add(field, data);
                }
            }

            return(dictionary);
        }
Пример #14
0
        // GET: api/User/5
        public User Get(int id)
        {
            User returnUser = new User();

            using (var db = new EModelsContext())
            {
                var eUser = db.sharepoint_users.Where(user => user.id.Equals(id)).Single();
                returnUser.id           = eUser.id;
                returnUser.name         = eUser.name;
                returnUser.email        = eUser.email;
                returnUser.phone        = eUser.phone;
                returnUser.userCode     = eUser.user_code;
                returnUser.permissionid = eUser.permissionid;
                returnUser.permission   = eUser.sharepoint_permissions == null ? "None" : eUser.sharepoint_permissions.type;
                returnUser.groupid      = eUser.groupid;
                returnUser.group        = eUser.sharepoint_usergroups == null ? "None" : eUser.sharepoint_usergroups.name;
            }
            return(returnUser);
        }
Пример #15
0
        // GET: api/AnalysisCode
        public IEnumerable <AnalysisCode> Get()
        {
            List <AnalysisCode> returnAnalysisCodes = new List <AnalysisCode>();

            using (var db = new EModelsContext())
            {
                var result = db.analysis_codes.OrderByDescending(ac => ac.id).ToList();

                foreach (var eAnalysisCode in result)
                {
                    AnalysisCode returnAnalysisCode = new AnalysisCode();
                    returnAnalysisCode.id   = eAnalysisCode.id;
                    returnAnalysisCode.code = eAnalysisCode.code;

                    returnAnalysisCodes.Add(returnAnalysisCode);
                }
            }

            return(returnAnalysisCodes);
        }
Пример #16
0
        // POST: api/User
        public void Post([FromBody] User data)
        {
            using (var db = new EModelsContext())
            {
                int permissionid = db.sharepoint_permissions.Where(perm => perm.type.Equals(data.permission)).SingleOrDefault().id;
                int groupid      = db.sharepoint_usergroups.Where(ug => ug.name.Equals(data.group)).SingleOrDefault().id;

                sharepoint_users user = new sharepoint_users
                {
                    name         = data.name,
                    email        = data.email,
                    phone        = data.phone,
                    user_code    = data.userCode,
                    permissionid = permissionid,
                    groupid      = groupid
                };
                db.sharepoint_users.Add(user);
                db.SaveChanges();
            }
        }
Пример #17
0
        // GET: api/Supplier
        public IEnumerable <Supplier> Get()
        {
            List <Supplier> returnSuppliers = new List <Supplier>();

            using (var db = new EModelsContext())
            {
                var result = db.suppliers.OrderByDescending(req => req.id).ToList();

                foreach (var eSupplier in result)
                {
                    Supplier returnSupplier = new Supplier();
                    returnSupplier.id   = eSupplier.id;
                    returnSupplier.name = eSupplier.name;

                    returnSuppliers.Add(returnSupplier);
                }
            }

            return(returnSuppliers);
        }
Пример #18
0
        // PUT: api/User/5
        public void Put(int id, [FromBody] User data)
        {
            using (var db = new EModelsContext())
            {
                var eUser = db.sharepoint_users.Where(user => user.id.Equals(id)).SingleOrDefault();

                int permissionid = db.sharepoint_permissions.Where(perm => perm.type.Equals(data.permission)).SingleOrDefault().id;
                int groupid      = db.sharepoint_usergroups.Where(ug => ug.name.Equals(data.group)).SingleOrDefault().id;


                if (eUser != null)
                {
                    eUser.name         = data.name;
                    eUser.email        = data.email;
                    eUser.phone        = data.phone;
                    eUser.user_code    = data.userCode;
                    eUser.permissionid = permissionid;
                    eUser.groupid      = data.groupid;
                    db.SaveChanges();
                }
            }
        }