public void subirCantidadDestacamento(int id, int sube) { RelJugadorRecursoHandlerEF jrHandler = new RelJugadorRecursoHandlerEF(ctx); var relJMHandler = new RelJugadorMapaHandlerEF(ctx); try { var r = ctx.RelJugadorDestacamento .Where(w => w.id == id) .SingleOrDefault(); if (r != null) { var dest = r.getShared(); DateTime ahora = DateTime.Now; TimeSpan tConstruccion = TimeSpan.FromMinutes(dest.destacamento.tiempoInicial * sube); r.finalizaConstruccion = ahora.Add(tConstruccion); List <Entities.Costo> costos = r.destacamento.calCostoXNivel(0, sube); jrHandler.restarCompra(r.colonia.id, costos); r.cantidad += sube; ctx.SaveChangesAsync().Wait(); relJMHandler.actualizarProduccionCapacidad(r.colonia.id); } } catch (Exception ex) { throw ex; } }
public RelJugadorEdificio subirNivel(int id) { RelJugadorRecursoHandlerEF jrHandler = new RelJugadorRecursoHandlerEF(ctx); try { var r = ctx.RelJugadorEdificio .Where(w => w.id == id) .SingleOrDefault(); if (r != null) { Boolean compro; var edi = r.getShared(); List <Entities.Costo> costos = r.edificio.calCostoXNivel(r.nivelE, 1); compro = jrHandler.restarCompra(r.colonia.id, costos); if (compro == false) { return(null); } DateTime ahora = DateTime.Now; TimeSpan tConstruccion = TimeSpan.FromSeconds(edi.edificio.tiempoInicial); r.finalizaConstruccion = ahora.Add(tConstruccion); ctx.SaveChangesAsync().Wait(); } return(r.getShared()); } catch (Exception ex) { throw ex; } }
public Boolean updateRelJugadorDestacamento(RelJugadorDestacamento rje) { RelJugadorRecursoHandlerEF jrHandler = new RelJugadorRecursoHandlerEF(ctx); var relJMHandler = new RelJugadorMapaHandlerEF(ctx); try { var r = ctx.RelJugadorDestacamento .Where(w => w.id == rje.id) .SingleOrDefault(); if (r != null) { var dest = r.getShared(); var cant = rje.cantidad - r.cantidad; if (!rje.getForceUpdate()) { List <Entities.Costo> costos = r.destacamento.calCostoXNivel(0, cant); Boolean compro = jrHandler.restarCompra(r.colonia.id, costos); if (compro == false) { return(false); } DateTime ahora = DateTime.Now; TimeSpan tConstruccion = TimeSpan.FromSeconds(dest.destacamento.tiempoInicial * cant); r.finalizaConstruccion = ahora.Add(tConstruccion); } else { r.cantidad = rje.cantidad; } ctx.SaveChangesAsync().Wait(); } return(true); } catch (Exception ex) { throw ex; } }