public static void CopyToData(this ActorInput input, Actor data, HttpPostedFileBase photo, IDaoCountry daoCountry, IDaoFilm daoFilm)
        {
            if (data.ID != input.ID)
            {
                throw new Exception("Cannot copy from foreign view to data");
            }

            data.Name      = input.Name;
            data.Surname   = input.Surname;
            data.Birth     = input.Birth;
            data.Death     = input.Death;
            data.Biography = input.Biography;

            if (input.CountryId != null)
            {
                data.Country = daoCountry.Find(input.CountryId);
            }

            data.RemoveAllFilms();
            if (input.FilmsStared != null)
            {
                foreach (var id in input.FilmsStared)
                {
                    var film = daoFilm.Find(id);

                    data.AddFilm(film);
                }
            }

            data.Gender = (Data.Models.Gender)input.Gender;

            if (photo != null && photo.ContentLength > 0)
            {
                try
                {
                    if (photo.ContentType.Contains("image"))
                    {
                        var filename = Guid.NewGuid().ToString() + Path.GetExtension(photo.FileName);

                        var path = Path.Combine(PathUtils.GetProjectDirectory(),
                                                "Cinematheque.WebSite\\images\\actors\\",
                                                filename);
                        photo.SaveAs(path);

                        data.PhotoFileName = filename;
                    }
                    else
                    {
                        throw new Exception("ERROR: Uploaded file is not image");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("ERROR:" + ex.Message.ToString());
                }
            }
        }
        public static Actor CreateActor(this ActorInput input, HttpPostedFileBase photo, IDaoCountry daoCountry, IDaoFilm daoFilm)

        {
            var actor = new Actor
            {
                Name      = input.Name,
                Surname   = input.Surname,
                Birth     = input.Birth,
                Death     = input.Death,
                Country   = daoCountry.Find(input.CountryId),
                Biography = input.Biography,
                Gender    = (Data.Models.Gender)input.Gender
            };

            if (photo != null && photo.ContentLength > 0)
            {
                try
                {
                    if (photo.ContentType.Contains("image"))
                    {
                        var filename = Guid.NewGuid().ToString() + Path.GetExtension(photo.FileName);

                        var path = Path.Combine(PathUtils.GetProjectDirectory(),
                                                "Cinematheque.WebSite\\images\\actors\\",
                                                filename);
                        photo.SaveAs(path);

                        actor.PhotoFileName = filename;
                    }
                    else
                    {
                        throw new Exception("ERROR: Uploaded file is not image");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("ERROR:" + ex.Message.ToString());
                }
            }
            else
            {
                actor.PhotoFileName = "default.jpg";
            }

            if (input.FilmsStared != null)
            {
                foreach (var id in input.FilmsStared)
                {
                    var film = daoFilm.Find(id);

                    actor.AddFilm(film);
                }
            }

            return(actor);
        }