public void EmergencyStatus_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            var message = new EmergencyStatus();

            TestUtilities.TestProperty(message, m => m.EmergencyState, EmergencyState.None, EmergencyState.GeneralEmergency);
            TestUtilities.TestProperty(message, m => m.Squawk, null, (short)1234);
        }
Beispiel #2
0
 //按工作人员和状态查询
 public static List <Emergency> QueryByWorkerAndStatus(string id, EmergencyStatus status)
 {
     //访问数据库,查询记录,返回记录
     using (var db = new CommunityEpidemicManagementSystemContext())
     {
         var query = db.Emergencies.Where(e => e.WorkerId == id && e.EmergState == status);
         return(query.ToList());
     }
 }
        public async Task AddRecipientAsync(
            string userHospitalId,
            string firstName,
            string middleName,
            string lastName,
            int age,
            double neededQuantity,
            EmergencyStatus recipientEmergency,
            BloodGroup bloodGroup,
            RhesusFactor rhesusFactor)
        {
            var hospitalData = this.hospitalDataRepository.All()
                               .FirstOrDefault(uhd => uhd.ApplicationUserId == userHospitalId);

            if (hospitalData == null)
            {
                throw new ArgumentException(GlobalConstants.NoHospitalDataErrorMessage);
            }

            if (firstName == null ||
                middleName == null ||
                lastName == null ||
                age == 0 ||
                neededQuantity == 0)
            {
                throw new ArgumentException(GlobalConstants.NotFullRecipientDataErrorMessage);
            }

            var recipient = new Recipient
            {
                FirstName          = firstName,
                MiddleName         = middleName,
                LastName           = lastName,
                Age                = age,
                NeededQuantity     = neededQuantity,
                RecipientEmergency = recipientEmergency,
                BloodGroup         = bloodGroup,
                RhesusFactor       = rhesusFactor,
            };

            var recipientHospitalData = new RecipientHospitalData
            {
                HospitalDataId = hospitalData.Id,
                RecipientId    = recipient.Id,
            };

            recipient.HospitalDataId = recipientHospitalData.HospitalDataId;

            await this.recipientsRepository.AddAsync(recipient);

            await this.recipientsRepository.SaveChangesAsync();

            await this.recipientHospitalDataRepository.AddAsync(recipientHospitalData);

            await this.recipientHospitalDataRepository.SaveChangesAsync();
        }
        public async Task <string> CreateRequestAsync(
            string userId,
            string content,
            DateTime publishedOn,
            EmergencyStatus emergencyStatus,
            BloodGroup bloodGroup,
            RhesusFactor rhesusFactor,
            double neededQuantity)
        {
            if (neededQuantity == 0)
            {
                throw new ArgumentException(GlobalConstants.NoQuantityErrrorMessage);
            }

            var hospitalData = this.hospitalDataRepository.All()
                               .Where(hd => hd.ApplicationUserId == userId)
                               .FirstOrDefault();

            if (hospitalData == null)
            {
                throw new ArgumentException(GlobalConstants.NoHospitalDataErrorMessage);
            }

            var location = this.locationDataRepository.All()
                           .FirstOrDefault(l => l.Id == hospitalData.LocationId);

            var request = new Request
            {
                HospitalName    = hospitalData.Name,
                Content         = content,
                PublishedOn     = publishedOn,
                EmergencyStatus = emergencyStatus,
                BloodGroup      = bloodGroup,
                RhesusFactor    = rhesusFactor,
                NeededQuantity  = neededQuantity,
                Location        = location,
            };

            request.HospitalId = hospitalData.Id;

            await this.requestsRepository.AddAsync(request);

            await this.requestsRepository.SaveChangesAsync();

            var userHospital = new HospitalDataRequest
            {
                HospitalDataId = hospitalData.Id,
                RequestId      = request.Id,
            };

            await this.requestsHospitalDataRepository.AddAsync(userHospital);

            await this.requestsHospitalDataRepository.SaveChangesAsync();

            return(request.Id);
        }
Beispiel #5
0
        public static string ConvertTo(EmergencyStatus status)
        {
            switch (status)
            {
            case EmergencyStatus.New:
                return("Nowe");

            case EmergencyStatus.TeamSent:
                return("Ekipa ratunkowa w drodze");

            case EmergencyStatus.Done:
                return("Zakończone");

            case EmergencyStatus.Rejected:
                return("Odrzucone");
            }
            return("");
        }
Beispiel #6
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (PhoneNumber != null)
            {
                p.Add(new KeyValuePair <string, string>("PhoneNumber", PhoneNumber.ToString()));
            }

            if (AreaCode != null)
            {
                p.Add(new KeyValuePair <string, string>("AreaCode", AreaCode));
            }

            if (ApiVersion != null)
            {
                p.Add(new KeyValuePair <string, string>("ApiVersion", ApiVersion));
            }

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (SmsApplicationSid != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsApplicationSid", SmsApplicationSid.ToString()));
            }

            if (SmsFallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsFallbackMethod", SmsFallbackMethod.ToString()));
            }

            if (SmsFallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsFallbackUrl", SmsFallbackUrl.ToString()));
            }

            if (SmsMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsMethod", SmsMethod.ToString()));
            }

            if (SmsUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsUrl", SmsUrl.ToString()));
            }

            if (StatusCallback != null)
            {
                p.Add(new KeyValuePair <string, string>("StatusCallback", StatusCallback.ToString()));
            }

            if (StatusCallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString()));
            }

            if (VoiceApplicationSid != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceApplicationSid", VoiceApplicationSid.ToString()));
            }

            if (VoiceCallerIdLookup != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString()));
            }

            if (VoiceFallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceFallbackMethod", VoiceFallbackMethod.ToString()));
            }

            if (VoiceFallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceFallbackUrl", VoiceFallbackUrl.ToString()));
            }

            if (VoiceMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceMethod", VoiceMethod.ToString()));
            }

            if (VoiceUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceUrl", VoiceUrl.ToString()));
            }

            if (EmergencyStatus != null)
            {
                p.Add(new KeyValuePair <string, string>("EmergencyStatus", EmergencyStatus.ToString()));
            }

            if (EmergencyAddressSid != null)
            {
                p.Add(new KeyValuePair <string, string>("EmergencyAddressSid", EmergencyAddressSid.ToString()));
            }

            if (TrunkSid != null)
            {
                p.Add(new KeyValuePair <string, string>("TrunkSid", TrunkSid.ToString()));
            }

            return(p);
        }
Beispiel #7
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (AccountSid != null)
            {
                p.Add(new KeyValuePair <string, string>("AccountSid", AccountSid.ToString()));
            }

            if (ApiVersion != null)
            {
                p.Add(new KeyValuePair <string, string>("ApiVersion", ApiVersion));
            }

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (SmsApplicationSid != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsApplicationSid", SmsApplicationSid.ToString()));
            }

            if (SmsFallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsFallbackMethod", SmsFallbackMethod.ToString()));
            }

            if (SmsFallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsFallbackUrl", Serializers.Url(SmsFallbackUrl)));
            }

            if (SmsMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsMethod", SmsMethod.ToString()));
            }

            if (SmsUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("SmsUrl", Serializers.Url(SmsUrl)));
            }

            if (StatusCallback != null)
            {
                p.Add(new KeyValuePair <string, string>("StatusCallback", Serializers.Url(StatusCallback)));
            }

            if (StatusCallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString()));
            }

            if (VoiceApplicationSid != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceApplicationSid", VoiceApplicationSid.ToString()));
            }

            if (VoiceCallerIdLookup != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceCallerIdLookup", VoiceCallerIdLookup.Value.ToString().ToLower()));
            }

            if (VoiceFallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceFallbackMethod", VoiceFallbackMethod.ToString()));
            }

            if (VoiceFallbackUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceFallbackUrl", Serializers.Url(VoiceFallbackUrl)));
            }

            if (VoiceMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceMethod", VoiceMethod.ToString()));
            }

            if (VoiceUrl != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceUrl", Serializers.Url(VoiceUrl)));
            }

            if (EmergencyStatus != null)
            {
                p.Add(new KeyValuePair <string, string>("EmergencyStatus", EmergencyStatus.ToString()));
            }

            if (EmergencyAddressSid != null)
            {
                p.Add(new KeyValuePair <string, string>("EmergencyAddressSid", EmergencyAddressSid.ToString()));
            }

            if (TrunkSid != null)
            {
                p.Add(new KeyValuePair <string, string>("TrunkSid", TrunkSid.ToString()));
            }

            if (VoiceReceiveMode != null)
            {
                p.Add(new KeyValuePair <string, string>("VoiceReceiveMode", VoiceReceiveMode.ToString()));
            }

            if (IdentitySid != null)
            {
                p.Add(new KeyValuePair <string, string>("IdentitySid", IdentitySid.ToString()));
            }

            if (AddressSid != null)
            {
                p.Add(new KeyValuePair <string, string>("AddressSid", AddressSid.ToString()));
            }

            return(p);
        }
Beispiel #8
0
 public PublicOrderEmergency(string description, EmergencyLevel emergencyLevel, RegistrationTime registrationTime, EmergencyStatus status) : base(description, emergencyLevel, registrationTime)
 {
     this.Status = status;
 }