Ejemplo n.º 1
0
        public bool CreateItem(Item item)
        {
            outpostwarsEntities entities = new outpostwarsEntities();

            try
            {
                // Add tew New Player into the player Collection
                entities.Items.Add(item);
                // Save changes
                return(entities.SaveChanges() == 1);
            }
            catch (DbEntityValidationException ex)
            {
                LogCriticalError(ex);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool CreateFleetBuilding(FleetBuilding fleetBuilding)
        {
            outpostwarsEntities entities = new outpostwarsEntities();

            try
            {
                // Add tew New Player into the player Collection
                entities.FleetBuildings.Add(fleetBuilding);
                // Save changes
                return(entities.SaveChanges() == 1);
            }
            catch (DbEntityValidationException ex)
            {
                LogCriticalError(ex);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public bool CreateBannedUserAgent(BannedUserAgent bannedUserAgent)
        {
            outpostwarsEntities entities = new outpostwarsEntities();

            try
            {
                // Add tew New Player into the player Collection
                entities.BannedUserAgents.Add(bannedUserAgent);
                // Save changes
                return(entities.SaveChanges() == 1);
            }
            catch (DbEntityValidationException ex)
            {
                LogCriticalError(ex);
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// A Common Method for Passing Critical Errors to Database
        ///
        /// </summary>
        /// <param name="ex">DbEntityValidationException</param>
        public void LogCriticalError(DbEntityValidationException ex)
        {
            // Create an entity of error
            outpostwarsEntities entities = new outpostwarsEntities();
            CriticalError       error    = new CriticalError();

            if (ex.Data != null)
            {
                error.Data = (string)ex.Data.ToString();
            }
            else
            {
                error.Data = " ";
            }
            if (error.HelpLink != null)
            {
                error.HelpLink = (string)ex.HelpLink.ToString();
            }
            else
            {
                error.HelpLink = " ";
            }
            if (error.EntityValidationErrors != null)
            {
                error.EntityValidationErrors = (string)ex.EntityValidationErrors.ToString();
            }
            else
            {
                error.EntityValidationErrors = " ";
            }
            if (error.InnerException != null)
            {
                error.InnerException = (string)ex.InnerException.ToString();
            }
            else
            {
                error.InnerException = " ";
            }
            if (error.Message != null)
            {
                error.Message = (string)ex.Message.ToString();
            }
            else
            {
                error.Message = " ";
            }
            if (error.Source != null)
            {
                error.Source = (string)ex.Source.ToString();
            }
            else
            {
                error.Source = " ";
            }
            if (error.StackTrace != null)
            {
                error.StackTrace = (string)ex.StackTrace.ToString();
            }
            else
            {
                error.StackTrace = " ";
            }
            if (error.TargetSite != null)
            {
                error.TargetSite = (string)ex.TargetSite.ToString();
            }
            else
            {
                error.TargetSite = " ";
            }


            // Add it to be saved
            entities.CriticalErrors.Add(error);

            // Now to save it
            entities.SaveChanges();
        }