Beispiel #1
0
        public int NewMessage(Message message)
        {
            var accident = new Accident();

            try
            {
                var db = new ecologyWatchEntities();

                accident.Accident_Description = message.Description;
                accident.Status_Id            = 1;
                accident.Date         = DateTime.Now;
                accident.Place_Lat    = message.Latitude;
                accident.Place_Long   = message.Longitude;
                accident.Place_Adress = message.PlaceName;
                accident.Situation_Id = message.SituationId;

                db.Accident.Add(accident);
                db.SaveChanges();
            }
            catch
            {
                return(-1);
            }

            if (accident.Accident_Id > 0)
            {
                return(accident.Accident_Id);
            }

            return(-1);
        }
Beispiel #2
0
        public int CreateNewnUser(User_Data user_data)
        {
            var temp = new User_Data();

            try
            {
                var db = new ecologyWatchEntities();

                var list = db.User_Data.Where(u => (u.Login == user_data.Login));
                if (list == null)
                {
                    temp.Login         = user_data.Login;
                    temp.Password_Hash = user_data.Password_Hash;
                    temp.Email         = user_data.Email;
                    temp.Is_Active     = true;
                    temp.Joined_On     = DateTime.Now;

                    db.User_Data.Add(temp);
                    db.SaveChanges();
                }
            }
            catch
            {
                return(-1);
            }

            if (temp.User_Id > 0)
            {
                return(temp.User_Id);
            }

            return(-1);
        }