Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public string DeleteClimate(WeatherClimate item)
        {
            string msg = string.Empty;

            item.ClimateActive = false;

            try
            {
                if (ModelState.IsValid)
                {
                    _genSvc.InactivateClimate(item);
                    msg = "Climate inactivated succesfully";
                }
                else
                {
                    msg = "Data validation not successfull";
                }
            }
            catch (Exception e)
            {
                msg = "Delete Climate. An error has ocurred";
            }

            return(msg);
        }
Exemple #4
0
        public string CreateClimate([Bind(Exclude = "ClimateID")] WeatherClimate item)
        {
            string msg = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    _genSvc.CreateClimate(item);
                    msg = "Climate created succesfully";
                }
                else
                {
                    msg = "Data validation not successfull";
                }
            }
            catch (Exception e)
            {
                msg = "Create Climate. An error has ocurred";
            }

            return(msg);
        }
Exemple #5
0
        public string EditClimate(WeatherClimate item)
        {
            string msg = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    _genSvc.UpdateClimate(item);
                    msg = "Climate saved succesfully";
                }
                else
                {
                    msg = "Data validation not successfull";
                }
            }
            catch (Exception e)
            {
                msg = "Edit Climate. An error has ocurred";
            }

            return(msg);
        }
Exemple #6
0
 public bool UpdateClimate(WeatherClimate item)
 {
     return(_genRepo.UpdateClimate(item));
 }
Exemple #7
0
 public bool InactivateClimate(WeatherClimate item)
 {
     return(_genRepo.InactivateClimate(item));
 }