public RiderViewModel() { //rider = new Rider(); individual = new Individual(); contact = new Contact(); contact.address = new Address(); contact.Email = new Email(); contact.phoneNumber = new PhoneNumber(); occupation = new RiderOccupation(); cycleUse = new RiderCycleUse(); }
private bool AddOrUpdateOccupation(riderDto riderDto) { bool blReturn = true; try { RiderOccupation occupation = riderDto.occupation; occupation.UserId = riderDto.Id; //Try validating on a per class basis here // blReturn = _riderRepository.AddIndividualToDatabase(individual); var dbValue = GetOccupationById(riderDto.Id); blReturn = (dbValue == null) ? _riderRepository.AddOccupationToDatabase(occupation) : _riderRepository.EditObjectInDatabase(dbValue, occupation); } catch (Exception ex) { } return(blReturn); }
public bool AddOccupationToDatabase(RiderOccupation occupation) { bool blSuccess = true; try { if (occupation == null) { return(false); } else { _db.RiderOccupations.Add(occupation); // KEY ISSUE HERE TAKE A LOOK } _db.SaveChanges(); } catch (Exception ex) { //Logger.Error("Failed AddIndividualToDatabase\n" + ex); //Logger.Error(ex.GetAllMessages()); blSuccess = false; } return(blSuccess); }