public string AddModWeather(Weather model, string delete = "0") { try { var db = new AmericaVirtualContext(); if (delete != "0") { var modDel = db.Weather.Where(x => x.Id == model.Id).FirstOrDefault(); db.Weather.Remove(modDel); AddLog("Eliminar Clima Fecha " + modDel.Date); } else { if (model.Id == 0) { db.Weather.Add(model); AddLog("Agregar Clima Fecha " + model.Date); } else { db.Entry(model).State = System.Data.Entity.EntityState.Modified; AddLog("Modificar Clima Fecha " + model.Date); } } db.SaveChanges(); return(model.Id.ToString()); } catch (Exception ex) { return("0"); } }
public void AddLog(string Services) { var db = new AmericaVirtualContext(); var Log = new Services_Log() { Service = Services, Date_Add = DateTime.Today }; db.Services_Log.Add(Log); db.SaveChanges(); }