public ActionResult Edit(Song editedSong, HttpPostedFileBase songFile, HttpPostedFileBase songImage)
        {
            if (ModelState.IsValid)
            {
                if (songFile != null)
                {
                    string fileName = StringGenerator.GenerateGuidName() + Path.GetExtension(songFile.FileName);
                    songFile.AddFileToServer(FilePath.SongServerPath, fileName, editedSong.SongFileName);
                    editedSong.SongFileName = fileName;
                }

                if (songImage != null)
                {
                    string imageName = editedSong.SongName + Path.GetExtension(songImage.FileName);
                    songImage.AddImageToServer(imageName, ImagePath.SongOriginalServerPath, 100, 100, ImagePath.SongThumbServerPath, editedSong.SongImageName);
                    editedSong.SongImageName = imageName;
                }

                unitOfWork.SongService.EditSong(editedSong);
                unitOfWork.save();
                return(RedirectToAction("Index", new { id = editedSong.SingerId }));
            }

            return(View(editedSong));
        }
        public ActionResult Create(Song newSong, HttpPostedFileBase songFile, HttpPostedFileBase songImage)
        {
            if (ModelState.IsValid)
            {
                if (songFile != null && songImage != null)
                {
                    string fileName  = StringGenerator.GenerateGuidName() + Path.GetExtension(songFile.FileName);
                    string imageName = newSong.SongName + Path.GetExtension(songImage.FileName);
                    songImage.AddImageToServer(imageName, ImagePath.SongOriginalServerPath, 100, 100, ImagePath.SongThumbServerPath);
                    songFile.AddFileToServer(FilePath.SongServerPath, fileName);
                    newSong.SongFileName  = fileName;
                    newSong.SongImageName = imageName;
                    newSong.CreateDate    = DateTime.Now;
                    unitOfWork.SongService.AddSong(newSong);
                    unitOfWork.save();
                    return(RedirectToAction("Index", new { id = newSong.SingerId }));
                }

                TempData["ErrorMessage"] = "لطفا فایل را وارد کنید";
            }

            return(View(newSong));
        }