private async void btnSignUp_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    var request = new UserInsertRequest
                    {
                        FirstName            = Convert.ToString(txtFirstName.Text),
                        LastName             = Convert.ToString(txtLastName.Text),
                        Email                = Convert.ToString(txtEmail.Text),
                        Username             = Convert.ToString(txtUsername.Text),
                        PhoneNumber          = Convert.ToString(txtPhone.Text),
                        Password             = Convert.ToString(txtPassword.Text),
                        PasswordConfirmation = Convert.ToString(txtPasswordConfirm.Text),
                        Image                = ImageHelper.SystemDrawingToByteArray(Resources.profile_picture),
                        Roles                = new List <int> {
                            1
                        }
                    };
                    await _service.SignUp(request);

                    PanelHelper.SwapPanels(this.Parent, this, new ucSignUp());
                }
                catch
                {
                    MessageBox.Show("Error");
                }
            }
        }
Exemple #2
0
        private void btnReport_Click_1(object sender, EventArgs e)
        {
            var datefrom = Convert.ToDateTime(dtpFrom.Value.ToString("O"));
            var dateto   = Convert.ToDateTime(dtpTo.Value.ToString("O"));

            PanelHelper.SwapPanels(this.Parent, this, new CourseSalesBetweenDatesReport(datefrom, dateto));
        }
Exemple #3
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var user = await userService.GetById <MUser>(_ID);

            if (ValidateChildren())
            {
                var        roleList       = clbRoles.CheckedItems.Cast <MRole>().Select(x => x.RoleID).ToList();
                List <int> uncheckedRoles = new List <int>();
                for (int i = 0; i < clbRoles.Items.Count; i++)
                {
                    if (!clbRoles.GetItemChecked(i))
                    {
                        int RoleID = clbRoles.Items.Cast <MRole>().ToList()[i].RoleID;
                        uncheckedRoles.Add(RoleID);
                    }
                }

                var request = new UserUpsertRequest
                {
                    FirstName                                     = txtFirstName.Text,
                    LastName                                      = txtLastName.Text,
                    Username                                      = txtUsername.Text,
                    Email                                         = txtEmail.Text,
                    PhoneNumber                                   = txtPhone.Text,
                    Image                                         = pbUserPicture.Image != null?ImageHelper.SystemDrawingToByteArray(pbUserPicture.Image) : null,
                                                    Roles         = roleList,
                                                    RolesToDelete = uncheckedRoles
                };

                await userService.Update <MUser>(_ID, request);

                MessageBox.Show("User have been updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PanelHelper.SwapPanels(this.Parent, this, new UserList());
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var request = new ArtistUpsertRequest
                {
                    Name    = txtName.Text,
                    Founded = txtFounded.Text,
                    Origin  = txtOrigin.Text,
                    Image   = pbArtistImage.Image != null?ImageHelper.SystemDrawingToByteArray(pbArtistImage.Image) : null
                };
                if (_ID.HasValue)
                {
                    await artistService.Update <MArtist>(_ID.Value, request);

                    MessageBox.Show("Artist updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    await artistService.Insert <MArtist>(request);

                    MessageBox.Show("Artist added successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                PanelHelper.SwapPanels(this.Parent, this, new ArtistList());
            }
        }
Exemple #5
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            var datefrom = Convert.ToDateTime(dtpFrom.Value);
            var dateto   = Convert.ToDateTime(dtpTo.Value);

            PanelHelper.SwapPanels(this.Parent, this, new AlbumSaleByDateReport(datefrom, dateto));
        }
        private async void btnSavee_Click(object sender, EventArgs e)
        {
            var user = await userService.GetById <MUser>(_ID);

            if (ValidateChildren())
            {
                var roleList = clbRoles.CheckedItems.Cast <MRole>().Select(x => x.RoleID).ToList();


                var request = new UserUpsertRequest
                {
                    FirstName                     = txtFirstName.Text,
                    LastName                      = txtLastName.Text,
                    Email                         = txtEmail.Text,
                    Username                      = txtUsername.Text,
                    PhoneNumber                   = txtPhone.Text,
                    Image                         = pbUserPicture.Image != null?ImageHelper.SystemDrawingToByteArray(pbUserPicture.Image) : null,
                                            Roles = roleList,
                };

                await userService.Update <MUser>(_ID, request);

                MessageBox.Show("Your information/informations have been updated successfully! Please log in to confirm changes.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PanelHelper.SwapPanels(this.Parent, this, new Welcome());
            }
        }
Exemple #7
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var user = await _userApiService.GetById <Model.User>(_ID);

                var request = new UserUpdateRequest
                {
                    FirstName            = user.FirstName,
                    LastName             = user.LastName,
                    Username             = user.Username,
                    Email                = user.Email,
                    PhoneNumber          = user.PhoneNumber,
                    Image                = user.Image,
                    Password             = txtNewPassword.Text,
                    PasswordConfirmation = txtNewPasswordConfirm.Text
                };

                await _userApiService.Update <Model.User>(_ID, request);

                MessageBox.Show("Success", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PanelHelper.SwapPanels(this.Parent, this, new ucAdminPasswordUpdate(_ID));
            }
            catch
            {
            }
        }
Exemple #8
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    var roleList = clbRoles.CheckedItems.Cast <MRole>().Select(i => i.RoleID).ToList();

                    var request = new UserUpsertRequest
                    {
                        FirstName                           = txtFirstName.Text,
                        LastName                            = txtLastName.Text,
                        Username                            = txtUsername.Text,
                        Email                               = txtEmail.Text,
                        PhoneNumber                         = txtPhone.Text,
                        Password                            = txtPassword.Text,
                        PasswordConfirmation                = txtPasswordConfirm.Text,
                        Image                               = pbUserImage.Image != null?ImageHelper.SystemDrawingToByteArray(pbUserImage.Image) : null,
                                                   Roles    = roleList,
                                                   FullName = txtFirstName.Text + " " + txtLastName.Text
                    };

                    await userService.Insert <MUser>(request);

                    MessageBox.Show("User added successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PanelHelper.SwapPanels(this.Parent, this, new UserList());
                }
                catch
                {
                    MessageBox.Show("You don't have permission to do that!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    var roleList = clbRoles.CheckedItems.Cast <Model.Role>().Select(i => i.ID).ToList();

                    var request = new Model.Requests.UserInsertRequest
                    {
                        FirstName                        = Convert.ToString(txtFirstName.Text),
                        LastName                         = Convert.ToString(txtLastName.Text),
                        Username                         = Convert.ToString(txtUsername.Text),
                        Email                            = Convert.ToString(txtEmail.Text),
                        PhoneNumber                      = Convert.ToString(txtPhoneNumber.Text),
                        Password                         = Convert.ToString(txtPassword.Text),
                        PasswordConfirmation             = Convert.ToString(txtPasswordConfirm.Text),
                        Image                            = pbUserImage.Image != null?ImageHelper.SystemDrawingToByteArray(pbUserImage.Image) : null,
                                                   Roles = roleList
                    };

                    await _apiService.Insert <Model.User>(request);

                    MessageBox.Show("Success", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PanelHelper.SwapPanels(this.Parent, this, new ucUserAdd());
                }
                catch
                {
                    MessageBox.Show("Error");
                }
            }
        }
Exemple #10
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    var request = new Model.Requests.GenreUpsertRequest
                    {
                        Name = Convert.ToString(txtName.Text),
                    };

                    if (_ID.HasValue)
                    {
                        await _apiService.Update <Model.Genre>(_ID.Value, request);
                    }
                    else
                    {
                        await _apiService.Insert <Model.Genre>(request);

                        PanelHelper.SwapPanels(this.Parent, this, new ucGenreUpsert());
                    }

                    MessageBox.Show("Success", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("Error");
                }
            }
        }
Exemple #11
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var course = await courseService.GetById <MCourse>(_courseID);

            var subcategory = await subcategoryService.GetById <MSubcategory>(course.SubcategoryID);

            if (ValidateChildren())
            {
                var request = new CourseUpsertRequest
                {
                    Name        = txtCourseName.Text,
                    Language    = txtLanguage.Text,
                    DateCreated = DateTime.Now,
                    Price       = float.Parse(txtPrice.Text),
                    //Convert.ToInt32(txtPrice.Text),
                    UserID      = course.UserID,
                    Description = txtDescription.Text,
                    Image       = pbCourseImage.Image != null?ImageHelper.SystemDrawingToByteArray(pbCourseImage.Image) : null,
                                      SubcategoryID = subcategory.SubcategoryID,
                                      URL           = txtURL.Text
                };
                await courseService.Update <MCourse>(_courseID, request);

                MessageBox.Show("Course updated successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PanelHelper.SwapPanels(this.Parent, this, new CourseList(_user, course));
            }
        }
Exemple #12
0
 private void btnDetails_Click(object sender, EventArgs e)
 {
     if (dgvCategories.CurrentRow != null)
     {
         int ID = Convert.ToInt32(dgvCategories.CurrentRow.Cells["CategoryID"].Value);
         PanelHelper.SwapPanels(this.Parent, this, new CategoryEdit(ID));
     }
 }
Exemple #13
0
 private void btnDetails_Click(object sender, EventArgs e)
 {
     if (dgvAlbums.CurrentRow != null)
     {
         int ID = Convert.ToInt32(dgvAlbums.CurrentRow.Cells["AlbumID"].Value);
         PanelHelper.SwapPanels(this.Parent, this, new AlbumUpsert(ID));
     }
 }
Exemple #14
0
 private void btnEditCourse_Click(object sender, EventArgs e)
 {
     if (dgvCourses.CurrentRow != null)
     {
         int ID = Convert.ToInt32(dgvCourses.CurrentRow.Cells["CourseID"].Value);
         PanelHelper.SwapPanels(this.Parent, this, new CourseEdit(_user, ID));
     }
 }
 private void btnEditPlaylist_Click(object sender, EventArgs e)
 {
     if (dgvPlaylists.CurrentRow != null)
     {
         int ID = Convert.ToInt32(dgvPlaylists.CurrentRow.Cells["ID"].Value);
         PanelHelper.SwapPanels(this.Parent, this, new ucPlaylistUpsert(ID));
     }
 }
        private async void btnDeletePlaylist_Click(object sender, EventArgs e)
        {
            if (dgvPlaylists.CurrentRow != null)
            {
                int ID = Convert.ToInt32(dgvPlaylists.CurrentRow.Cells["ID"].Value);
                await _apiService.Delete <dynamic>(ID);

                PanelHelper.SwapPanels(this.Parent, this, new ucPlaylistList());
            }
        }
Exemple #17
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (dgvCourses.Rows.Count == 0)
     {
         MessageBox.Show("You don't have any available course .");
     }
     else
     {
         int ID = Convert.ToInt32(dgvCourses.CurrentRow.Cells["CourseID"].Value);
         PanelHelper.SwapPanels(this.Parent, this, new CourseAddVideoLecture(_user, ID));
     }
 }
Exemple #18
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var subcategoryCategories = Convert.ToInt32(cbCategory.SelectedValue);

            var request = new SubcategoryUpsertRequest()
            {
                Name       = txtName.Text,
                CategoryID = subcategoryCategories
            };

            await subcategoryService.Insert <MSubcategory>(request);

            MessageBox.Show("Subcategory added successfully", "Success", MessageBoxButtons.OK);
            PanelHelper.SwapPanels(this.Parent, this, new CourseAdd(_user, _course));
        }
Exemple #19
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var category = await categoryService.GetById <MCategory>(Convert.ToInt32(cbCategory.SelectedValue));

            var request = new SubcategoryUpsertRequest()
            {
                Name         = txtName.Text,
                CategoryID   = category.CategoryID,
                CategoryName = category.Name
            };

            await subcategoryService.Insert <MSubcategory>(request);

            MessageBox.Show("Subcategory added successfully", "Success", MessageBoxButtons.OK);
            PanelHelper.SwapPanels(this.Parent, this, new SubcategoryList());
        }
Exemple #20
0
 private async void btnDeleteCourse_Click(object sender, EventArgs e)
 {
     if (dgvCourses.CurrentRow != null)
     {
         var result = false;
         int ID     = Convert.ToInt32(dgvCourses.CurrentRow.Cells["CourseID"].Value);
         if (MessageBox.Show("Do you really want to delete this course?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             result = await courseService.Delete <dynamic>(ID);
         }
         if (result == true)
         {
             MessageBox.Show("You have deleted course successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         PanelHelper.SwapPanels(this.Parent, this, new CourseList(_user, _course));
     }
 }
Exemple #21
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var user = await categoryService.GetById <MCategory>(_ID);

            if (ValidateChildren())
            {
                var request = new CategoryUpsertRequest
                {
                    Name = txtName.Text
                };

                await categoryService.Update <MCategory>(_ID, request);

                MessageBox.Show("Category have been updated successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PanelHelper.SwapPanels(this.Parent, this, new CategoryList());
            }
        }
        private async void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvSubcategories.CurrentRow != null)
            {
                bool result = false;
                int  ID     = Convert.ToInt32(dgvSubcategories.CurrentRow.Cells["SubcategoryID"].Value);

                if (MessageBox.Show("Do you really want to delete this subcategory?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    result = await subcategoryService.Delete <dynamic>(ID);
                }
                if (result == true)
                {
                    MessageBox.Show("You have deleted subcategory successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                PanelHelper.SwapPanels(this.Parent, this, new SubcategoryList());
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var albumTrack = albumTracks.Select(i => i.TrackID).ToList();

                var request = new AlbumUpsertRequest()
                {
                    Name           = txtName.Text,
                    YearOfRelease  = Convert.ToInt32(txtReleaseYear.Text),
                    ArtistID       = Convert.ToInt32(cbArtist.SelectedValue),
                    GenreID        = Convert.ToInt32(cbGenre.SelectedValue),
                    Image          = ImageHelper.SystemDrawingToByteArray(pbAlbumPicture.Image),
                    NumberOfTracks = albumTrack.Count(),
                    Price          = Convert.ToInt32(txtPrice.Text),
                    About          = txtAbout.Text,
                    Tracks         = albumTrack
                };

                if (_ID.HasValue)
                {
                    var tracksToDelete = _album.AlbumTracks
                                         .Where(i => !albumTracks.Any(id => id.TrackID == i.TrackID))
                                         .Select(i => i.TrackID)
                                         .ToList();

                    request.TracksToDelete = tracksToDelete;

                    await albumService.Update <MAlbum>(_ID.Value, request);

                    MessageBox.Show("Album updated succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    PanelHelper.SwapPanels(this.Parent, this, new AlbumList());
                }
                else
                {
                    await albumService.Insert <MAlbum>(request);

                    MessageBox.Show("Album added succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    PanelHelper.SwapPanels(this.Parent, this, new AlbumList());
                }
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var playlistTrack = playlistTracks.Select(i => i.TrackID).ToList();

                var request = new PlaylistUpsertRequest
                {
                    Name   = txtName.Text,
                    Image  = ImageHelper.SystemDrawingToByteArray(pbPlaylistPicture.Image),
                    Tracks = playlistTrack,
                };

                if (ID.HasValue)
                {
                    var tracksToDelete = _playlist.PlaylistTracks
                                         .Where(i => !playlistTracks.Any(id => id.TrackID == i.TrackID))
                                         .Select(i => i.TrackID)
                                         .ToList();

                    request.TracksToDelete = tracksToDelete;
                    request.UserID         = _playlist.UserID;
                    request.Username       = _playlist.User.Username;
                    request.CreatedAt      = _playlist.CreatedAt;

                    await playlistService.Update <MPlaylist>(ID.Value, request);

                    MessageBox.Show("Playlist Updated Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PanelHelper.SwapPanels(this.Parent, this, new PlaylistList());
                }
                else
                {
                    request.CreatedAt = DateTime.Now.ToString();
                    request.UserID    = SignedInUser.User.UserID;
                    request.Username  = SignedInUser.User.Username;
                    await playlistService.Insert <MPlaylist>(request);

                    MessageBox.Show("Playlist Added Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PanelHelper.SwapPanels(this.Parent, this, new PlaylistList());
                }
            }
        }
Exemple #25
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var LectureSection = Convert.ToInt32(cbSection.SelectedValue);
                var request        = new VideoLectureUpsertRequest
                {
                    LectureName = txtLectureName.Text,
                    SectionID   = LectureSection,
                    UploadedOn  = DateTime.Now,
                    CourseID    = _ID,
                    URL         = txtURL.Text
                };
                await videoLectureService.Insert <MVideoLecture>(request);

                MessageBox.Show("Video lecture added successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

                PanelHelper.SwapPanels(this.Parent, this, new CourseAddVideoLecture(_user, request.CourseID));
                ClearControls();
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.stop();

            byte[] MP3File     = File.ReadAllBytes(axWindowsMediaPlayer1.URL);
            var    trackGenres = Convert.ToInt32(cbGenres.SelectedValue);
            int    trackArtist = Convert.ToInt32(cbArtist.SelectedValue);
            var    request     = new TrackUpsertRequest()
            {
                Name     = txtName.Text,
                Length   = txtLength.Text,
                MP3File  = MP3File,
                GenreID  = trackGenres,
                ArtistID = trackArtist
            };

            await trackService.Insert <MTrack>(request);

            MessageBox.Show("Track added successfully", "Success", MessageBoxButtons.OK);
            PanelHelper.SwapPanels(this.Parent, this, new TrackList());
        }
Exemple #27
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    var request = new CategoryUpsertRequest
                    {
                        Name = txtName.Text
                    };

                    await categoryService.Insert <MCategory>(request);

                    MessageBox.Show("Category added Successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PanelHelper.SwapPanels(this.Parent, this, new CourseAddSubcategory(_user, _course));
                }
                catch
                {
                    MessageBox.Show("You don't have permission to do that!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var playlistTracks = _playlistTracks.Select(i => i.ID).ToList();


                var request = new PlaylistUpsertRequest
                {
                    Name   = Convert.ToString(txtName.Text),
                    Image  = ImageHelper.SystemDrawingToByteArray(pbPlaylistImage.Image),
                    Tracks = playlistTracks
                };

                if (_ID.HasValue)
                {
                    var tracksToDelete = _playlist.PlaylistTracks
                                         .Where(i => !playlistTracks.Any(j => j.Equals(i.TrackID)))
                                         .Select(i => i.TrackID)
                                         .ToList();

                    request.TracksToDelete = tracksToDelete;
                    request.UserID         = _playlist.UserID;
                    request.CreatedAt      = _playlist.CreatedAt;

                    await _playlistApiService.Update <Model.Playlist>(_ID.Value, request);
                }
                else
                {
                    request.CreatedAt = DateTime.Now.ToString();
                    request.UserID    = SignedInUserHelper.User.ID;
                    await _playlistApiService.Insert <Model.Playlist>(request);

                    PanelHelper.SwapPanels(this.Parent, this, new ucPlaylistUpsert());
                }

                MessageBox.Show("Success", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var albumTracks = _albumTracks.Select(i => i.ID).ToList();

                var request = new AlbumUpsertRequest()
                {
                    Name        = Convert.ToString(txtName.Text),
                    ReleaseYear = Convert.ToInt32(txtReleaseYear.Text),
                    ArtistID    = Convert.ToInt32(cbArtist.SelectedValue),
                    Image       = ImageHelper.SystemDrawingToByteArray(pbAlbumImage.Image),
                    Tracks      = albumTracks
                };

                if (_ID.HasValue)
                {
                    var tracksToDelete = _album.AlbumTracks
                                         .Where(i => !albumTracks.Any(id => id.Equals(i.TrackID)))
                                         .Select(i => i.TrackID)
                                         .ToList();

                    request.TracksToDelete = tracksToDelete;

                    await _albumApiService.Update <Model.Album>(_ID.Value, request);
                }
                else
                {
                    await _albumApiService.Insert <Model.Album>(request);

                    var parent = this.Parent;

                    PanelHelper.SwapPanels(this.Parent, this, new ucAlbumUpsert());
                }

                MessageBox.Show("Success", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #30
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                var request = new GenreUpsertRequest
                {
                    Name = txtName.Text
                };
                if (_ID.HasValue)
                {
                    await genreService.Update <MGenre>(_ID.Value, request);

                    MessageBox.Show("Genre updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    await genreService.Insert <MGenre>(request);

                    MessageBox.Show("Genre added successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                PanelHelper.SwapPanels(this.Parent, this, new GenreList());
            }
        }