コード例 #1
0
ファイル: AdminController.cs プロジェクト: riddar/PictureDB
        public Admin CreateAdmin(string id, string adminName, string password)
        {
            try
            {
                using (DocumentClient Client = new DocumentClient(new Uri(Context.EndpointUrl), Context.Authkey))
                {
                    _Admin = GetAdminByAdminName(adminName);

                    if (_Admin == null)
                    {
                        Admin newAdmin = new Admin()
                        {
                            Id = id, AdminName = adminName, Password = password
                        };
                        Client.CreateDocumentAsync(Context.GetCollectionByName("Pictures").SelfLink, newAdmin);
                        return(newAdmin);
                    }
                    else
                    {
                        return(_Admin);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
        public Picture CreatePicture(string pictureName, string pictureUrl)
        {
            try
            {
                using (DocumentClient Client = new DocumentClient(new Uri(Context.EndpointUrl), Context.Authkey))
                {
                    _picture = GetPictureByPictureName(pictureName);

                    if (_picture == null)
                    {
                        Picture newPicture = new Picture()
                        {
                            PictureName = pictureName, PictureUrl = pictureUrl, Valid = false
                        };
                        Client.CreateDocumentAsync(Context.GetCollectionByName("Pictures").SelfLink, newPicture);
                        _picture = GetPictureByPictureName(pictureName);
                        return(newPicture);
                    }
                    else
                    {
                        return(_picture);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #3
0
        public PictureUser CreatePictureUser(string userName, string email, List <string> pictureId)
        {
            try
            {
                using (DocumentClient Client = new DocumentClient(new Uri(Context.EndpointUrl), Context.Authkey))
                {
                    _PictureUser = GetPictureUserByUserName(userName);

                    if (_PictureUser == null)
                    {
                        PictureUser newPictureUser = new PictureUser()
                        {
                            Username = userName, Email = email, PictureId = pictureId
                        };
                        Client.CreateDocumentAsync(Context.GetCollectionByName("PictureUsers").SelfLink, newPictureUser);
                        _PictureUser = GetPictureUserByUserName(userName);
                        return(newPictureUser);
                    }
                    else
                    {
                        return(_PictureUser);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }