public void DeleteImage_Invoke_InvokesBusinesLayerDeleteImage()
        {
            // Arrange
            using (ShimsContext.Create())
            {
                var imageToDelete         = string.Empty;
                var loadBrowseTableCalled = false;
                var showBrowseCalled      = false;
                ShimNewFile.DeleteImageString                      = (image) => imageToDelete = image;
                Shimgallery.AllInstances.loadBrowseTable           = gallery => loadBrowseTableCalled = true;
                Shimgallery.AllInstances.showBrowseObjectEventArgs = (gallery, obj, eventArgs) => showBrowseCalled = true;
                ShimUserControl.AllInstances.ServerGet             = obj => new ShimHttpServerUtility();
                ShimHttpServerUtility.AllInstances.MapPathString   = (obj, input) => DeleteImage;

                using (var testObject = new gallery())
                {
                    var privateObject = new PrivateObject(testObject);
                    privateObject.SetFieldOrProperty(ImagePreview, new Image());

                    // Act
                    testObject.deleteImage(null, new CommandEventArgs(null, DeleteImage));

                    // Assert
                    testObject.ShouldSatisfyAllConditions(() => imageToDelete.ShouldBe(DeleteImage), () => loadBrowseTableCalled.ShouldBeTrue(), () => showBrowseCalled.ShouldBeTrue());
                }
            }
        }
        public void ShowBrowse_Invoke_SetsOrResetsVisibility()
        {
            // Arrange
            using (ShimsContext.Create())
            {
                Shimgallery.AllInstances.loadBrowseTable = gallery => { };

                using (var testObject = new gallery())
                {
                    InitControls(testObject);

                    // Act
                    testObject.showBrowse(null, new CommandEventArgs(null, DeleteImage));

                    // Assert
                    testObject.ShouldSatisfyAllConditions(
                        () => _tabPreview?.Visible.ShouldBeFalse(),
                        () => _tabUpload?.Visible.ShouldBeTrue(),
                        () => _tabBrowse?.Visible.ShouldBeTrue(),
                        () => _panelBrowse?.Visible.ShouldBeTrue(),
                        () => _panelPreview?.Visible.ShouldBeFalse(),
                        () => _panelUpload?.Visible.ShouldBeFalse(),
                        () => _panelBrowseOther?.Visible.ShouldBeFalse());
                }
            }
        }
        public void Insert(gallery gallery)
        {
            //gallery.GalleryID = NextIdValue();
            //_galleries.Add(gallery);

            _ds.Insert(gallery);
        }
Exemple #4
0
        public ActionResult GalleryEdit(gallery _gallery, HttpPostedFileBase fileUpload, FormCollection collection)
        {
            try
            {
                if (collection["removeImage"] != null && Convert.ToBoolean(collection["removeImage"].Split(',')[0]))
                {
                    _gallery.Directory = "";
                    if ((System.IO.File.Exists(Server.MapPath("~") + _gallery.Directory)))
                    {
                        System.IO.File.Delete(Server.MapPath("~") + _gallery.Directory);
                    }
                }

                if (fileUpload != null)
                {
                    _gallery.Directory = DAL.DatabaseHelper.UploadFile(DataSettings.GALLERY_DIRECTORY, fileUpload, Server);
                }

                DAL.GalleryDAL.GalleryRepository GalleryRepo = new DAL.GalleryDAL.GalleryRepository();
                GalleryRepo.Update(_gallery, Server.MapPath("~"));

                return(RedirectToAction("Gallery"));
            }
            catch
            {
                return(View());
            }
        }
        public void DeleteImage_Invoke_InvokesBusinesLayerDeleteImage()
        {
            // Arrange
            using (ShimsContext.Create())
            {
                var imageToDelete = string.Empty;
                ShimFileInfo.AllInstances.Delete                   = input => { };
                Shimgallery.AllInstances.loadBrowseTable           = gallery => { };
                Shimgallery.AllInstances.showBrowseObjectEventArgs = (gallery, obj, eventArgs) => { };
                ShimUserControl.AllInstances.ServerGet             = obj => new ShimHttpServerUtility();
                ShimHttpServerUtility.AllInstances.MapPathString   = (obj, input) =>
                {
                    imageToDelete = input;
                    return(DeleteImage);
                };
                ShimUserControl.AllInstances.ResponseGet     = (obj) => new ShimHttpResponse().Instance;
                ShimHttpResponse.AllInstances.RedirectString = (obj, input) => { };

                using (var testObject = new gallery())
                {
                    var privateObject = new PrivateObject(testObject);
                    privateObject.SetFieldOrProperty(ImagePreview, new Image());

                    // Act
                    testObject.deleteImage(null, new CommandEventArgs(null, DeleteImage));

                    // Assert
                    imageToDelete.ShouldBe(DeleteImage);
                }
            }
        }
Exemple #6
0
        public ActionResult GalleryDetails(int id)
        {
            DAL.GalleryDAL.GalleryRepository GalleryRepo = new DAL.GalleryDAL.GalleryRepository();
            gallery _gallery = GalleryRepo.SelectOne(id);

            return(View(_gallery));
        }
        public List <gallery> Read()
        {
            List <gallery> galleries = new List <gallery>();

            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();

                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT [GalleryID],[Directory],[Description]");
                sb.Append("FROM [careerfair].[gallery]");
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            gallery gallery = new gallery();

                            gallery.GalleryID   = DatabaseHelper.CheckNullInt(reader, 0);
                            gallery.Directory   = DatabaseHelper.CheckNullString(reader, 1);
                            gallery.Description = DatabaseHelper.CheckNullString(reader, 2);

                            galleries.Add(gallery);
                        }
                    }
                }
            }
            return(galleries);
        }
        public void Update(gallery gallery, string serverPath, string oldPath)
        {
            if (oldPath != gallery.Directory)
            {
                if ((System.IO.File.Exists(serverPath + oldPath)))
                {
                    System.IO.File.Delete(serverPath + oldPath);
                }
            }

            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("UPDATE [careerfair].[gallery]");
                sb.Append("SET [Directory] = @param1, [Description] = @param2 ");
                sb.Append("WHERE [GalleryID] = " + gallery.GalleryID);
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.Parameters.Add("@param1", SqlDbType.NVarChar, int.MaxValue).Value = (object)gallery.Directory ?? DBNull.Value;
                    command.Parameters.Add("@param2", SqlDbType.NVarChar, int.MaxValue).Value = (object)gallery.Description ?? DBNull.Value;
                    command.CommandType = System.Data.CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            gallery gallery = db.gallery.Find(id);

            db.gallery.Remove(gallery);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #10
0
    private bool shouldClick;     // True if the laser hits the next button



    void Awake()
    {
        //this also just reads the gallery script, and finds the things it needs there
        button = gallery_wall.GetComponent <gallery> ();

        //reference to the controller?
        trackedObj = GetComponent <SteamVR_TrackedObject>();
    }
Exemple #11
0
 public ActionResult Edit([Bind(Include = "GalleryID,Directory,Description")] gallery gallery)
 {
     if (ModelState.IsValid)
     {
         gr.Update(gallery, Server.MapPath("~"));
         return(RedirectToAction("Index"));
     }
     return(View(gallery));
 }
Exemple #12
0
 public ActionResult Edit([Bind(Include = "Id,photo,name,clubID")] gallery gallery)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gallery).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gallery));
 }
Exemple #13
0
        public ActionResult Create([Bind(Include = "GalleryID,Directory,Description")] gallery gallery)
        {
            if (ModelState.IsValid)
            {
                gr.Insert(gallery);
                return(RedirectToAction("Index"));
            }

            return(View(gallery));
        }
        public void Update(gallery gallery, string serverPath)
        {
            var oldGallery = _galleries.Where(g => g.GalleryID == gallery.GalleryID).FirstOrDefault();

            if (oldGallery != null)
            {
                _galleries.Remove(oldGallery);
                _galleries.Add(gallery);
                _ds.Update(gallery, serverPath, oldGallery.Directory);
            }
        }
Exemple #15
0
        public ActionResult Create([Bind(Include = "Id,photo,name,clubID")] gallery gallery)
        {
            if (ModelState.IsValid)
            {
                db.gallery.Add(gallery);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gallery));
        }
 public ActionResult Edit([Bind(Include = "id,description,address,latitude,longitude,maxCapacity,name,cleaningFee,daily,hourly,minimumBooking,monthly,securityDeposit,weekly,surface,galleryOwner_id")] gallery gallery)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gallery).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.galleryOwner_id = new SelectList(db.user, "id", "role", gallery.galleryOwner_id);
     return(View(gallery));
 }
Exemple #17
0
        public ActionResult GalleryDelete(int id, gallery _gallery)
        {
            try
            {
                DAL.GalleryDAL.GalleryRepository GalleryRepo = new DAL.GalleryDAL.GalleryRepository();
                GalleryRepo.Delete(id, Server.MapPath("~"));

                return(RedirectToAction("Gallery"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #18
0
        // GET: Gallery/Delete/5
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            gallery gallery = gr.SelectOne(id);

            if (gallery == null)
            {
                return(HttpNotFound());
            }
            return(View(gallery));
        }
        // GET: galleries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            gallery gallery = db.gallery.Find(id);

            if (gallery == null)
            {
                return(HttpNotFound());
            }
            return(View(gallery));
        }
        // GET: galleries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            gallery gallery = db.gallery.Find(id);

            if (gallery == null)
            {
                return(HttpNotFound());
            }
            ViewBag.galleryOwner_id = new SelectList(db.user, "id", "role", gallery.galleryOwner_id);
            return(View(gallery));
        }
        public void BorderWidth_SetValue_ReturnsSetValue()
        {
            // Arrange
            using (var testObject = new gallery())
            {
                const string TestValue     = "10";
                var          privateObject = new PrivateObject(testObject);
                privateObject.SetFieldOrProperty(ImageRepeater, new DataList());

                // Act
                testObject.borderWidth = TestValue;

                // Assert
                testObject.borderWidth.ShouldBe($"{TestValue}px");
            }
        }
        private void InitControls(gallery testObject)
        {
            _privateObject = new PrivateObject(testObject);
            _privateObject.SetFieldOrProperty(TabPreview, new LinkButton());
            _privateObject.SetFieldOrProperty(TabUpload, new LinkButton());
            _privateObject.SetFieldOrProperty(TabBrowse, new LinkButton());
            _privateObject.SetFieldOrProperty(PanelBrowse, new Panel());
            _privateObject.SetFieldOrProperty(PanelPreview, new Panel());
            _privateObject.SetFieldOrProperty(PanelUpload, new Panel());

            _tabPreview   = _privateObject.GetFieldOrProperty(TabPreview) as LinkButton;
            _tabUpload    = _privateObject.GetFieldOrProperty(TabUpload) as LinkButton;
            _tabBrowse    = _privateObject.GetFieldOrProperty(TabBrowse) as LinkButton;
            _panelBrowse  = _privateObject.GetFieldOrProperty(PanelBrowse) as Panel;
            _panelPreview = _privateObject.GetFieldOrProperty(PanelPreview) as Panel;
            _panelUpload  = _privateObject.GetFieldOrProperty(PanelUpload) as Panel;
        }
Exemple #23
0
        public ActionResult GalleryCreate(gallery _gallery, HttpPostedFileBase fileUpload, FormCollection collection)
        {
            try
            {
                if (fileUpload != null)
                {
                    _gallery.Directory = DAL.DatabaseHelper.UploadFile(DataSettings.GALLERY_DIRECTORY, fileUpload, Server);
                }

                DAL.GalleryDAL.GalleryRepository GalleryRepo = new DAL.GalleryDAL.GalleryRepository();
                GalleryRepo.Insert(_gallery);

                return(RedirectToAction("Gallery"));
            }
            catch
            {
                return(View());
            }
        }
        public void Insert(gallery gallery)
        {
            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("INSERT INTO [careerfair].[gallery]([Directory],[Description])");
                string values = "VALUES(@param1, @param2)";
                sb.Append(values);
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.Parameters.Add("@param1", SqlDbType.NVarChar, int.MaxValue).Value = (object)gallery.Directory ?? DBNull.Value;
                    command.Parameters.Add("@param2", SqlDbType.NVarChar, int.MaxValue).Value = (object)gallery.Description ?? DBNull.Value;
                    command.CommandType = System.Data.CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
        public void ShowUpload_Invoke_SetsOrResetsVisibility()
        {
            // Arrange
            using (var testObject = new gallery())
            {
                InitControls(testObject);

                // Act
                testObject.showUpload(null, new CommandEventArgs(null, DeleteImage));

                // Assert
                testObject.ShouldSatisfyAllConditions(
                    () => _tabPreview?.Visible.ShouldBeFalse(),
                    () => _tabUpload?.Visible.ShouldBeTrue(),
                    () => _tabBrowse?.Visible.ShouldBeTrue(),
                    () => _panelBrowse?.Visible.ShouldBeFalse(),
                    () => _panelPreview?.Visible.ShouldBeFalse(),
                    () => _panelUpload?.Visible.ShouldBeTrue());
            }
        }
        public ActionResult Edit([Bind(Include = "id,phtosource")] gallery gallery, HttpPostedFileBase photos)
        {
            if (photos.ContentType != "image/jpeg" && photos.ContentType != "image/png" && photos.ContentType != "image/gif")
            {
                return(Content("fayl duzgun deyil"));
            }


            if (ModelState.IsValid)
            {
                string filname = DateTime.Now.ToString("yyyyMMddHHmmss") + photos.FileName;
                var    myfile  = System.IO.Path.Combine(Server.MapPath("~/Uploads"), photos.FileName);
                photos.SaveAs(myfile);
                gallery.phtosource      = photos.FileName;
                db.Entry(gallery).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(gallery));
        }
        public void Remove(gallery gallery, string serverPath)
        {
            if ((System.IO.File.Exists(serverPath + gallery.Directory)))
            {
                System.IO.File.Delete(serverPath + gallery.Directory);
            }

            using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("DELETE FROM [careerfair].[gallery]");
                sb.Append("WHERE [GalleryID] = " + gallery.GalleryID);
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = System.Data.CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
 public void add(gallery entity)
 {
     glr.Insert(entity.Name, entity.Type);
 }
        public gallery SelectOne(int id)
        {
            gallery selectedGallery = _galleries.Where(g => g.GalleryID == id).FirstOrDefault();

            return(selectedGallery);
        }