Пример #1
0
        public bool Guardar(AlquilerInsertarViewModel entity)
        {
            Cancha cancha = new Cancha();

            for (var i = 0; i < 1; i++)
            {
                cancha = context.Cancha.FirstOrDefault(x => x.Ccancha == entity.canchas.ElementAt(i).Ccancha);
            }
            Alquiler alquiler = new Alquiler {
                Cequipo        = entity.Cequipo,
                Ccancha        = cancha.Ccancha,
                DfechaInicio   = entity.DfechaInicio,
                DfechaRegistro = entity.DfechaRegistro,
                NumHoras       = entity.NumHoras,
                Mdescuento     = 0,
                Mtotal         = entity.NumHoras * cancha.MprecioHora,
                Fpagado        = false,
            };

            try {
                context.Alquiler.Add(alquiler);
                context.SaveChanges();
                foreach (var p in entity.participantes)
                {
                    DetalleParticipante dp = new DetalleParticipante {
                        Calquiler     = alquiler.Calquiler,
                        Cparticipante = p.Cparticipante,
                        Mcuota        = alquiler.Mtotal / entity.participantes.Count(),
                        FpartePagada  = false,
                        Ncupos        = 1,
                    };
                    context.DetalleParticipante.Add(dp);
                }
                context.SaveChanges();
            }
            catch (System.Exception) {
                return(false);
            }
            return(true);
        }
 public bool Update(DetalleParticipante entity)
 {
     throw new NotImplementedException();
 }