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(); } }
public void addNewShooting(UserModel user, ShootingTypesModel shootingType, PaymentTypesModel paymentType, CaliberModel caliber) { dbRepository.addNewShooting(user, shootingType, paymentType, caliber); }