Beispiel #1
0
        public bool CreateClimate(WeatherClimate item)
        {
            bool result = false;

            try
            {
                using (RCID_DWHEntities context = new RCID_DWHEntities())
                {
                    byte newid = context.Weather_Climate.OrderByDescending(u => u.ClimateID).FirstOrDefault().ClimateID;
                    newid++;

                    Weather_Climate efItem = new Weather_Climate()
                    {
                        ClimateID     = newid,
                        ClimateActive = true,
                        ClimateName   = item.ClimateName
                    };

                    context.Weather_Climate.Add(efItem);

                    if (context.SaveChanges() > 0)
                    {
                        result = true;
                    }
                }
            }
            catch (Exception e) { throw e; }
            return(result);
        }
Beispiel #2
0
        public bool UpdateClimate(WeatherClimate item)
        {
            bool result = false;

            try
            {
                using (RCID_DWHEntities context = new RCID_DWHEntities())
                {
                    Weather_Climate efItem = context.Weather_Climate.Where(b => b.ClimateID == item.ClimateID).FirstOrDefault();

                    if (efItem == null)
                    {
                        return(result);
                    }

                    efItem.ClimateName   = item.ClimateName;
                    efItem.ClimateActive = item.ClimateActive;

                    if (context.SaveChanges() > 0)
                    {
                        result = true;
                    }
                }
            }
            catch (Exception) { }
            return(result);
        }