Exemplo n.º 1
0
        /// <summary>
        /// Add new director
        /// </summary>
        /// <param name="director"> director </param>
        /// <returns> status add </returns>
        public int AddNewDirector(DirectorModel director)
        {
            using (ctx = new FilmDataContext())
            {
                if (director == null)
                {
                    return(-1);
                }

                //Create director
                DataObject.EF.Director addDirector = new DataObject.EF.Director()
                {
                    DirectorID       = director.DirectorID,
                    DirectorName     = director.DirectorName,
                    DirectorGender   = director.DirectorGender,
                    DirectorBirthday = director.DirectorBirthday,
                    DirectorImg      = director.DirectorImg,
                    DirectorStatus   = director.DirectorStatus,
                    DirectorDescribe = director.DirectorDescribe
                };
                // Add director
                ctx.Directors.Add(addDirector);
                // return 1 if success, 0 if fail
                return(ctx.SaveChanges());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Remove director
        /// </summary>
        /// <param name="director"> director </param>
        /// <returns> status remove </returns>
        public int RemoveDirector(DirectorModel director)
        {
            using (FilmDataContext database = new FilmDataContext())
            {
                if (director == null)
                {
                    return(-1);
                }
                else
                {
                    DataObject.EF.Director _tDirector = new DataObject.EF.Director()
                    {
                        DirectorStatus   = director.DirectorStatus,
                        DirectorBirthday = director.DirectorBirthday,
                        DirectorDescribe = director.DirectorDescribe,
                        DirectorGender   = director.DirectorGender,
                        DirectorID       = director.DirectorID,
                        DirectorImg      = director.DirectorImg,
                        DirectorName     = director.DirectorName
                    };
                    // Remove director
                    database.Directors.Remove(_tDirector);

                    // return status add ( return 1 if success, 0 if fail
                    return(database.SaveChanges());
                }
            }
        }