public void changeShootsOnShooting(int shoots, int shootingId) { using (var db = new srsDBEntities()) { Shooting shooting = db.Shooting.Where(i => i.Id == shootingId).First(); shooting.Shoots = shoots; db.SaveChanges(); } }
public void startStopShooting(ShootingModel shootingModel) { using (var db = new srsDBEntities()) { Shooting shooting = db.Shooting.Where(i => i.Id == shootingModel.Id).FirstOrDefault(); if (shooting.isDone == true) { shooting.isDone = false; } else { shooting.isDone = true; } db.SaveChanges(); } }
public void addNewShooting(UserModel user, ShootingTypesModel shootingType, PaymentTypesModel paymentType, CaliberModel caliber) { using (var db = new srsDBEntities()) { Shooting newShooting = new Shooting() { CreationDate = DateTime.Now, ShootingType = AutoMapper.Mapper.Map <ShootingTypes>(shootingType).Id, PaymentType = AutoMapper.Mapper.Map <PaymentTypes>(paymentType).Id, Caliber = AutoMapper.Mapper.Map <Caliber>(caliber).Id }; var dbUser = db.User.FirstOrDefault(i => i.Id == user.Id); dbUser.Shooting.Add(newShooting); db.SaveChanges(); } }