public static void InjectRequestIfRequires(this ICurrentCaller caller, IRequest request) { Guard.AgainstNull(() => caller, caller); Guard.AgainstNull(() => request, request); var requiresRequest = caller as IRequiresRequest; if (requiresRequest != null) { requiresRequest.Request = request; } }
public void CreateInvoice(ICurrentCaller caller, string appointmentId, decimal amount, string currency) { caller.GuardAgainstNull(nameof(caller)); var payment = new PaymentEntity(this.logger, this.idFactory); payment.CreateInvoice(new AppointmentPayment(appointmentId.ToIdentifier(), amount, currency)); var created = this.storage.Save(payment); this.logger.LogInformation("Payment {Id} was created for appointment {Appointment} by {Caller}", created.Id, appointmentId, caller.Id); }
public SearchResults <Car> SearchAvailable(ICurrentCaller caller, DateTime fromUtc, DateTime toUtc, SearchOptions searchOptions, GetOptions getOptions) { caller.GuardAgainstNull(nameof(caller)); var cars = this.storage.SearchAvailable(fromUtc, toUtc, searchOptions); this.recorder.TraceInformation("Available carsApplication were retrieved by {Caller}", caller.Id); return(searchOptions.ApplyWithMetadata(cars .ConvertAll(c => WithGetOptions(c.ToCar(), getOptions)))); }
public Doctor GetDoctor(ICurrentCaller caller, string doctorId) { caller.GuardAgainstNull(nameof(caller)); var doctor = this.storage.GetDoctor(doctorId.ToIdentifier()); if (doctor == null) { throw new ResourceNotFoundException(); } return(doctor.ToDoctor()); }
public SearchResults <Doctor> SearchAvailableDoctors(ICurrentCaller caller, DateTime fromUtc, DateTime toUtc, SearchOptions searchOptions, GetOptions getOptions) { caller.GuardAgainstNull(nameof(caller)); var doctors = this.storage.SearchAvailableDoctors(fromUtc, toUtc, searchOptions); this.logger.LogInformation("Available doctors were retrieved by {Caller}", caller.Id); return(searchOptions.ApplyWithMetadata(doctors .ConvertAll(doc => WithGetOptions(doc.ToDoctor(), getOptions)))); }
public Person Create(ICurrentCaller caller, string firstName, string lastName) { caller.GuardAgainstNull(nameof(caller)); var person = new PersonEntity(this.logger, this.idFactory, this.emailService); person.SetName(new PersonName(firstName, lastName)); var created = this.storage.Save(person); this.logger.LogInformation("Person {Id} was created by {Caller}", created.Id, caller.Id); return(created.ToPerson()); }
public Car Create(ICurrentCaller caller, int year, string make, string model) { caller.GuardAgainstNull(nameof(caller)); var owner = this.personsService.Get(caller.Id) .ToOwner(); var car = new CarEntity(this.recorder, this.idFactory); car.SetOwnership(new VehicleOwner(owner.Id)); car.SetManufacturer(new Manufacturer(year, make, model)); var created = this.storage.Save(car); this.recorder.TraceInformation("Car {Id} was created by {Caller}", created.Id, caller.Id); return(created.ToCar()); }
public Clinic Create(ICurrentCaller caller, int country, string city, string street) { caller.GuardAgainstNull(nameof(caller)); var owner = this.personsService.Get(caller.Id) .ToClinicOwner(); var clinic = new ClinicEntity(this.logger, this.idFactory); clinic.SetOwnership(new ClinicsDomain.ClinicOwner(owner.Id)); clinic.SetLocation(new Location(country, city, street)); var created = this.storage.Save(clinic); this.logger.LogInformation("Clinic {Id} was created by {Caller}", created.Id, caller.Id); return(created.ToClinic()); }
public Person Get(ICurrentCaller caller, string id, GetOptions options) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); if (id.ToIdentifier() == CurrentCallerConstants.AnonymousUserId) { return(Person.Anonymous); } var person = this.storage.GetPerson(id.ToIdentifier()); if (person == null) { throw new ResourceNotFoundException(); } return(person.ToPerson()); }
public Car Register(ICurrentCaller caller, string id, string jurisdiction, string number) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); var car = this.storage.Load(id.ToIdentifier()); if (id == null) { throw new ResourceNotFoundException(); } var plate = new LicensePlate(jurisdiction, number); car.Register(plate); var updated = this.storage.Save(car); this.recorder.TraceInformation("Car {Id} was registered with plate {Plate}, by {Caller}", id, plate, caller.Id); return(updated.ToCar()); }
public Car Offline(ICurrentCaller caller, string id, DateTime fromUtc, DateTime toUtc) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); fromUtc.GuardAgainstMinValue(nameof(fromUtc)); toUtc.GuardAgainstMinValue(nameof(toUtc)); var car = this.storage.Load(id.ToIdentifier()); if (id == null) { throw new ResourceNotFoundException(); } car.Offline(new TimeSlot(fromUtc, toUtc)); var updated = this.storage.Save(car); this.recorder.TraceInformation("Car {Id} was taken offline from {From} until {To}, by {Caller}", id, fromUtc, toUtc, caller.Id); return(updated.ToCar()); }
public Clinic OfflineDoctor(ICurrentCaller caller, string id, DateTime fromUtc, DateTime toUtc) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); fromUtc.GuardAgainstMinValue(nameof(fromUtc)); toUtc.GuardAgainstMinValue(nameof(toUtc)); var clinic = this.storage.Load(id.ToIdentifier()); if (clinic == null) { throw new ResourceNotFoundException(); } clinic.OfflineDoctor(new TimeSlot(fromUtc, toUtc)); var updated = this.storage.Save(clinic); this.logger.LogInformation("Doctor {Id} was taken offline from {From} until {To}, by {Caller}", id, fromUtc, toUtc, caller.Id); return(updated.ToClinic()); }
public Clinic Register(ICurrentCaller caller, string id, string jurisdiction, string certificateNumber) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); var clinic = this.storage.Load(id.ToIdentifier()); if (clinic == null) { throw new ResourceNotFoundException(); } var license = new ClinicLicense(jurisdiction, certificateNumber); clinic.Register(license); var updated = this.storage.Save(clinic); this.logger.LogInformation("Clinic {Id} was registered with plate {License}, by {Caller}", id, license, caller.Id); return(updated.ToClinic()); }
public Doctor RegisterDoctor(ICurrentCaller caller, string id, string firstName, string lastName) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); var doctor = this.personsService.Create(firstName, lastName) .ToClinicDoctor(); var clinic = this.storage.Load(id.ToIdentifier()); if (clinic == null) { throw new ResourceNotFoundException(); } clinic.RegisterDoctor(doctor); this.storage.Save(clinic); this.logger.LogInformation("Doctor {Doctor} was registered to clinic {Clinic}, by {Caller}", doctor.Id, clinic.Id, caller.Id); return(doctor.ToDoctor()); }
public void UpdateManagerEmail(ICurrentCaller caller, string managerId, string email) { caller.GuardAgainstNull(nameof(caller)); //TODO: find the cars that have this manager, and update them, then raise email notification }
public Appointment Create(ICurrentCaller caller, in DateTime startUtc, in DateTime endUtc, string doctorId)