public static void Main(string[] args) { MyMoneyManagerEntities context = new MyMoneyManagerEntities(); #region Calcolo report IPASE //var calcolo = context.Movimenti.Where(q => q.IDCategoriaIphase != null).GroupBy(q => q.IDCategoriaIphase).Sum(q => new { q. }q.Sum(e => e.Importo)).; //var calcoloipase = context.Movimenti.Where(q => q.IDCategoriaIphase != null).GroupBy(x => new { x.IDCategoriaIphase, DbFunctions.CreateDateTime(x.DataValuta.Value.Year, x.DataValuta.Value.Month, x.DataValuta.Value.Day, 0, 0, 0).Value.Year, DbFunctions.CreateDateTime(x.DataValuta.Value.Year, x.DataValuta.Value.Month, x.DataValuta.Value.Day, 0, 0, 0).Value.Month }).SelectMany(rr => rr.Select(r => new { IDCategoria = rr.Key.IDCategoriaIphase, Anno = rr.Key.Year, Mese = rr.Key.Month, Totale = rr.Sum(t => t.Importo) })); //foreach (var item in calcoloipase) //{ // tReportCategorieMeseIpase rep = new tReportCategorieMeseIpase(); // rep.IDCategoria = item.IDCategoria; // rep.Anno = item.Anno; // rep.Mese = item.Mese; // rep.Importo = item.Totale; // context.tReportCategorieMeseIpase.Add(rep); //} var collection = context.vReportCategorieUbi; foreach (var item in collection) { tReportCategorieMeseUbi rep = new tReportCategorieMeseUbi(); rep.IDCategoria = item.IDCategoria; rep.Anno = item.Anno; rep.Mese = item.Mese; rep.Importo = item.Totale; context.tReportCategorieMeseUbi.Add(rep); } context.SaveChanges(); var collection2 = context.v_ReportCategorieIpase; foreach (var item in collection2) { tReportCategorieMeseIpase rep1 = new tReportCategorieMeseIpase(); rep1.IDCategoria = item.IDCategoriaIphase; rep1.Anno = item.Anno; rep1.Mese = item.Mese; rep1.Importo = item.Totale; context.tReportCategorieMeseIpase.Add(rep1); } context.SaveChanges(); #endregion #region Calcolo report UBI //var calcolo = context.Movimenti.Where(q => q.IDCategoriaIphase != null).GroupBy(q => q.IDCategoriaIphase).Sum(q => new { q. }q.Sum(e => e.Importo)).; var calcoloubi = context.Movimenti.Where(q => q.IDCategoria != null).GroupBy(x => new { x.IDCategoria, DbFunctions.CreateDateTime(x.DataContabile.Value.Year, x.DataContabile.Value.Month, x.DataContabile.Value.Day, 0, 0, 0).Value.Year, DbFunctions.CreateDateTime(x.DataContabile.Value.Year, x.DataContabile.Value.Month, x.DataContabile.Value.Day, 0, 0, 0).Value.Month }).SelectMany(rr => rr.Select(r => new { IDCategoria = rr.Key.IDCategoria, Anno = rr.Key.Year, Mese = rr.Key.Month, Totale = rr.Sum(t => t.Importo) })); foreach (var item in calcoloubi) { tReportCategorieMeseUbi rep = new tReportCategorieMeseUbi(); rep.IDCategoria = item.IDCategoria; rep.Anno = item.Anno; rep.Mese = item.Mese; rep.Importo = item.Totale; context.tReportCategorieMeseUbi.Add(rep); } context.SaveChanges(); #endregion }
public async Task <ActionResult> DeleteConfirmed(int id) { tReportCategorieMeseUbi tReportCategorieMeseUbi = await db.tReportCategorieMeseUbi.FindAsync(id); db.tReportCategorieMeseUbi.Remove(tReportCategorieMeseUbi); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "ID,IDCategoria,Anno,Mese,Importo")] tReportCategorieMeseUbi tReportCategorieMeseUbi) { if (ModelState.IsValid) { db.Entry(tReportCategorieMeseUbi).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.IDCategoria = new SelectList(db.CategorieUbiBanca, "ID", "Descrizione", tReportCategorieMeseUbi.IDCategoria); return(View(tReportCategorieMeseUbi)); }
// GET: tReportCategorieMeseUbis/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tReportCategorieMeseUbi tReportCategorieMeseUbi = await db.tReportCategorieMeseUbi.FindAsync(id); if (tReportCategorieMeseUbi == null) { return(HttpNotFound()); } return(View(tReportCategorieMeseUbi)); }
// GET: tReportCategorieMeseUbis/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tReportCategorieMeseUbi tReportCategorieMeseUbi = await db.tReportCategorieMeseUbi.FindAsync(id); if (tReportCategorieMeseUbi == null) { return(HttpNotFound()); } ViewBag.IDCategoria = new SelectList(db.CategorieUbiBanca, "ID", "Descrizione", tReportCategorieMeseUbi.IDCategoria); return(View(tReportCategorieMeseUbi)); }