public T Delete(int id) { var entity = _context.Set <TDatabase>().Find(id); _context.Set <TDatabase>().Remove(entity); _context.SaveChanges(); return(_mapper.Map <T>(entity)); }
public eDentalClinic.Model.User Insert(UserInsertRequest request) { if (request.Password != request.ConfirmPassword) { throw new UserException("Password and password confirm do not match!"); } var entity = _mapper.Map <Database.User>(request); entity.PasswordSalt = HashGenerator.GenerateSalt(); entity.PasswordHash = HashGenerator.GenerateHash(entity.PasswordSalt, request.Password); _context.Users.Add(entity); _context.SaveChanges(); return(_mapper.Map <eDentalClinic.Model.User>(entity)); }
public override eDentalClinic.Model.Appointment Insert(AppointmentInsertRequest model) { var entity = _context.Appointments.Where(x => x.DentistID == model.DentistID).ToList(); foreach (var e in entity) { if ((e.StartDate == model.StartDate) || (e.StartDate < model.StartDate && e.EndDate > model.StartDate) || (e.StartDate < model.EndDate && e.EndDate > model.EndDate)) { return(null); } } Database.Appointment appointment = _mapper.Map <Database.Appointment>(model); _context.Appointments.Add(appointment); _context.SaveChanges(); return(_mapper.Map <eDentalClinic.Model.Appointment>(appointment)); }