Exemplo n.º 1
0
        public ActionResult EditCaller(Caller callerModel)
        {
            if (ModelState.IsValid)
            {
                tblCaller caller = new tblCaller()
                {
                    Active          = callerModel.Active,
                    Assignment      = callerModel.Assignment,
                    CallerEmail     = callerModel.CallerEmail,
                    MobilePhone     = callerModel.MobilePhone,
                    CallerFirstName = callerModel.CallerFirstName,
                    CallerLastName  = callerModel.CallerLastName,
                    CallerPager     = callerModel.CallerPager,
                    OfficePhone     = callerModel.OfficePhone,
                    CallerTitle     = callerModel.CallerTitle,
                    ID = callerModel.CallerId
                };
                try
                {
                    using (var context = new lifeflightapps())
                    {
                        context.tblCallers.AddOrUpdate(caller);

                        //db.tblCallers.Attach(caller);
                        //var entry = db.Entry(caller);
                        //entry.State = System.Data.Entity.EntityState.Modified;
                        context.SaveChanges();
                        var    preferredNumber = context.tblCallerPreferredNumbers.Where(x => x.CallerId == callerModel.CallerId).FirstOrDefault();
                        string number          = GetPreferredNumber(callerModel, callerModel.PreferredNumberType);
                        if (preferredNumber != null)
                        {
                            preferredNumber.PreferredNumber = number;
                            preferredNumber.PreferredType   = callerModel.PreferredNumberType;
                            context.SaveChanges();
                        }
                        else
                        {
                            tblCallerPreferredNumber cpn = new tblCallerPreferredNumber()
                            {
                                CallerId        = callerModel.CallerId,
                                PreferredNumber = number,
                                PreferredType   = callerModel.PreferredNumberType
                            };

                            context.tblCallerPreferredNumbers.Add(cpn);
                            context.SaveChanges();
                        }
                        return(RedirectToAction("Index"));
                    }
                }
                catch (DataException dx)
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                    throw dx;
                }
            }
            return(View(callerModel));
        }
Exemplo n.º 2
0
        public ActionResult Create(Caller CallerModel)
        {
            int    CallerId        = 0;
            var    preferred       = CallerModel.PreferredNumberType;
            string preferredNumber = string.Empty;

            try
            {
                tblCaller tcaller = new tblCaller()
                {
                    Active          = true,
                    Assignment      = CallerModel.Assignment,
                    CallerEmail     = CallerModel.CallerEmail,
                    OfficePhone     = CallerModel.OfficePhone,
                    CallerFirstName = CallerModel.CallerFirstName,
                    CallerLastName  = CallerModel.CallerLastName,
                    CallerPager     = CallerModel.CallerPager,
                    MobilePhone     = CallerModel.MobilePhone,
                    CallerTitle     = CallerModel.CallerTitle
                };
                preferredNumber = GetPreferredNumber(CallerModel, preferred);
                tblCallerPreferredNumber callerPreferredNumber = new tblCallerPreferredNumber()
                {
                    PreferredNumber = preferredNumber,
                    PreferredType   = CallerModel.PreferredNumberType
                };
                using (var context = new lifeflightapps())
                {
                    try
                    {
                        context.tblCallers.Add(tcaller);
                        context.SaveChanges();
                        CallerId = tcaller.ID;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }


                    callerPreferredNumber.CallerId = CallerId;

                    context.tblCallerPreferredNumbers.Add(callerPreferredNumber);
                    context.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add the insurance xref EMS reference
        /// </summary>
        /// <param name="InsuranceId"></param>
        /// <param name="Agencies"></param>
        /// <returns></returns>
        public JsonResult AddInsAgencies(int InsuranceId, string Agencies)
        {
            string[] selectedAgencies = Agencies.Split(',');
            //var insagencies = db.tblInsuranceEmsXrefs.Where(x => x.InsuranceProviderID == InsuranceId).Select(x => x.AgencyId);
            //if (insagencies.Any())
            //{

            //}
            //else
            //{
            foreach (var item in selectedAgencies)
            {
                tblInsuranceEmsXref xref = new tblInsuranceEmsXref()
                {
                    Active              = true,
                    AgencyId            = Convert.ToInt32(item),
                    InsuranceProviderID = InsuranceId
                };

                using (var context = new lifeflightapps())
                {
                    context.tblInsuranceEmsXrefs.Add(xref);
                    context.SaveChanges();
                }
            }
            //}
            return(Json(JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        //[HttpPost]
        //public ActionResult DestinationList(string SearchDestination)
        //{
        //    List<Destination> destinations = new List<Destination>();
        //    DestinationViewModel viewModel = new DestinationViewModel();


        //    if (string.IsNullOrWhiteSpace(SearchDestination))
        //    {
        //        destinations = viewModel.RetrieveDestinations();
        //    }
        //    else
        //    {
        //        //destinations = viewModel.retrieveDestinations();
        //        try
        //        {
        //            string[] splitTaskName = SearchDestination.Split(',');
        //            string destinationName = splitTaskName[0].ToString();
        //            string statecode = splitTaskName[2].ToString();
        //            Union_Facilities facilities = new Union_Facilities();
        //            using (var context = new lifeflightapps())
        //            {
        //                facilities = context.Union_Facilities.Where(d => d.NAME == destinationName && d.STATE == statecode).FirstOrDefault();
        //                Destination destination = new Destination()
        //                {
        //                    DestinationName = facilities.NAME,
        //                    Address = facilities.ADDRESS,
        //                    City = facilities.CITY,
        //                    County = facilities.COUNTY,
        //                    State = facilities.STATE,
        //                    Zip = facilities.ZIP,
        //                    Phone = facilities.PHONE
        //                };
        //                destinations.Add(destination);
        //            }
        //            //destinations = viewModel.RetrieveDesiredDestinations(SearchDestination);
        //        }
        //        catch (Exception ex)
        //        {

        //            throw ex;
        //        }

        //    }

        //    return View(destinations);
        //}


        public ActionResult AddDestination(Destination destination)
        {
            if (string.IsNullOrEmpty(destination.DestinationName))
            {
                Destination  model        = new Destination();
                RequestModel requestModel = new RequestModel();
                model.StatesList = requestModel.GetStatesList().ToList();
                return(View(model));
            }
            else
            {
                using (var context = new lifeflightapps())
                {
                    tblNursingHome nursingHome = new tblNursingHome()
                    {
                        Name    = destination.DestinationName,
                        Address = destination.Address,
                        City    = destination.City,
                        County  = destination.County,
                        State   = destination.State,
                        Zip     = Convert.ToDouble(destination.Zip),
                        Phone   = destination.Phone
                    };

                    context.tblNursingHomes.Add(nursingHome);
                    context.SaveChanges();
                    int id = nursingHome.NursingHomeID;
                    return(RedirectToAction("GetDestinationDetails", new { DestinationId = id }));
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patientDemographics"></param>
        /// <returns></returns>
        private int PatientEntry(Patient patient)
        {
            int        patientId;
            tblPatient tPatient = new tblPatient()
            {
                FirstName   = patient.FirstName,
                LastName    = patient.LastName,
                Address     = patient.Address ?? "N/A",
                Age         = patient.Age ?? 0,
                City        = patient.City ?? "N/A",
                DateOfBirth = (!string.IsNullOrEmpty(patient.DOB)) ? Convert.ToDateTime(patient.DOB) : Convert.ToDateTime("01/01/1900"),
                Phone       = patient.Phone ?? "N/A",
                Social      = patient.Social ?? "N/A",
                State       = patient.State ?? "N/A",
                Weight      = Convert.ToInt32(patient.Weight),
                WeightUnit  = patient.WeightUnit,
                MrNumber    = patient.MRN,
                Zip         = patient.Zip ?? "N/A",
                CreatedBy   = User.Identity.Name,
                CreatedDate = DateTime.Now
            };

            using (var context = new lifeflightapps())
            {
                context.tblPatients.Add(tPatient);
                context.SaveChanges();
                patientId = tPatient.PatientID;
            }
            return(patientId);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="callerId"></param>
        /// <param name="destinationId"></param>
        /// <param name="dischargeTime"></param>
        /// <param name="insuranceId"></param>
        /// <param name="censusId"></param>
        /// <param name="selectedEmsAgency"></param>
        /// <param name="mrNumber"></param>
        /// <param name="patientId"></param>
        /// <param name="specialInstructions"></param>
        /// <param name="lifeSupport"></param>
        /// <returns></returns>
        private int DischargeRequestEntry(int callerId, int destinationId, string dischargeTime, int insuranceId, int censusId, string selectedEmsAgency, string mrNumber, string CaseNumber, int patientId, string specialInstructions, string lifeSupport, int pickupId, string requestType, string requestStatus, string notes, string appointmentTime)
        {
            int                  dischargerequestId;
            DateTime?            dischargeRequestTime = string.IsNullOrEmpty(dischargeTime) ? (DateTime?)null : Convert.ToDateTime(dischargeTime);
            tblDischargeRequest1 tdischargeRequest    = new tblDischargeRequest1()
            {
                CallReceivedBy      = User.Identity.Name, //Environment.UserName,
                CallReceivedDate    = DateTime.Now,
                CallerID            = callerId,
                DestinationID       = destinationId,
                DischargeTime       = dischargeRequestTime,
                InsuranceID         = insuranceId,
                LocationID          = censusId,
                ModeOfTransport     = selectedEmsAgency,
                MrNumber            = mrNumber,
                CaseNumber          = CaseNumber,
                PatientID           = patientId,
                SpecialInstructions = specialInstructions,
                Notes           = notes,
                LifeSupport     = lifeSupport,
                PickupID        = pickupId,
                RequestType     = requestType,
                RequestStatusID = Convert.ToInt32(requestStatus),
                AppointmentTime = string.IsNullOrEmpty(appointmentTime) ? (DateTime?)null : Convert.ToDateTime(appointmentTime)
            };

            using (var context = new lifeflightapps())
            {
                context.tblDischargeRequests1.Add(tdischargeRequest);
                context.SaveChanges();
                dischargerequestId = tdischargeRequest.RequestID;

                tblAuditLog auditLog = new tblAuditLog()
                {
                    APPNAME     = "DTM",
                    IDFROMAPP   = dischargerequestId,
                    MRNUMBER    = mrNumber,
                    CREATEDBY   = User.Identity.Name,
                    CREATEDON   = DateTime.Now,
                    UPDATENOTES = $"New request of type {requestType} has been created"
                };

                context.tblAuditLogs.Add(auditLog);
                context.SaveChanges();
            }
            return(dischargerequestId);
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="insurances"></param>
        /// <param name="mrNumber"></param>
        /// <returns></returns>
        private int InsuranceEntry(InsuranceInformation insurances, string mrNumber)
        {
            int             insuranceId;
            tblMbrInsurance tinsurance;

            if (insurances != null)
            {
                tinsurance = new tblMbrInsurance()
                {
                    FinancialName  = insurances.FinancialName,
                    PayorName      = insurances.Payorname,
                    PayorID        = Convert.ToInt32(insurances.PayorId),
                    PlanID         = Convert.ToInt32(insurances.PlanId),
                    PlanName       = insurances.PlanName,
                    PlanType       = insurances.PlanType,
                    SubscriberName = insurances.SubscriberName,
                    MrNumber       = mrNumber,
                    Effective      = insurances.EffectiveDate,
                    Termination    = insurances.TerminationDate,
                    FillingOrder   = insurances.FilingOrder,
                    InsuranceID    = insurances.InsuranceId,
                    MedipacPlanID  = insurances.MedipacPlanId,
                    CreatedBy      = User.Identity.Name,
                    CreatedDate    = DateTime.Now
                };
            }
            else
            {
                tinsurance = new tblMbrInsurance()
                {
                    FinancialName  = "N/A",
                    PayorName      = "N/A",
                    PayorID        = 999,
                    PlanID         = 999,
                    PlanName       = "N/A",
                    PlanType       = "N/A",
                    SubscriberName = "N/A",
                    MrNumber       = mrNumber,
                    Effective      = DateTime.Now,
                    Termination    = DateTime.Now,
                    FillingOrder   = 999,
                    InsuranceID    = 999,
                    MedipacPlanID  = "N/A",
                    CreatedBy      = User.Identity.Name,
                    CreatedDate    = DateTime.Now
                };
            }
            using (var context = new lifeflightapps())
            {
                context.tblMbrInsurances.Add(tinsurance);
                context.SaveChanges();
                insuranceId = tinsurance.MbrInsuranceID;
            }
            return(insuranceId);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Update the insurance informaiton
 /// </summary>
 /// <param name="InsuranceID"></param>
 /// <param name="Name"></param>
 /// <param name="Description"></param>
 /// <param name="Phone"></param>
 /// <param name="Fax"></param>
 /// <param name="PreAuth"></param>
 /// <param name="OwnPaper"></param>
 /// <param name="Instructions"></param>
 /// <returns></returns>
 public JsonResult UpdateInsuranceInfo(int InsuranceID, string Name, string Description, string Phone, string Fax, bool PreAuth, bool OwnPaper, string Instructions)
 {
     using (var context = new lifeflightapps())
     {
         var ins = context.tblInsuranceAgencies.Find(InsuranceID);
         ins.INSAGENCYNAME    = Name;
         ins.DESCRIPTION      = Description;
         ins.INSURANCEPHONE   = Phone;
         ins.INSURANCEFAX     = Fax;
         ins.HASOWNPAPEROWORK = OwnPaper;
         ins.PREAUTHREQUIRED  = PreAuth;
         ins.INSTRUCTIONS     = Instructions;
         ins.UPDATEDBY        = User.Identity.Name;
         ins.UPDATEDON        = DateTime.Now;
         context.SaveChanges();
     }
     return(Json(JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="specialNeeds"></param>
        /// <param name="patientId"></param>
        private void DischargeNeedsEntry(List <SelectListItem> specialNeeds, int patientId)
        {
            specialNeeds = specialNeeds.Where(s => s.Selected == true).ToList();
            foreach (var item in specialNeeds)
            {
                tblDischargeNeed tdischargeneed = new tblDischargeNeed()
                {
                    patientid      = patientId,
                    specialneedsid = Convert.ToInt32(item.Value),
                    active         = true
                };

                using (var context = new lifeflightapps())
                {
                    context.tblDischargeNeeds.Add(tdischargeneed);
                    context.SaveChanges();
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="coverages"></param>
        /// <param name="mrNumber"></param>
        /// <returns></returns>
        private int CoverageEntry(CoverageInfo coverages, string mrNumber)
        {
            int            coverageId;
            tblMbrCoverage tcoverage;

            if (coverages != null)
            {
                tcoverage = new tblMbrCoverage()
                {
                    CoverageTypeID   = coverages.TypeId,
                    CoverageTypeName = coverages.Typename,
                    IsActive         = coverages.IsActive,
                    MrNumber         = mrNumber,
                    VerifiedByUser   = coverages.VerifiedByUser,
                    VerifiedDate     = coverages.VerifiedDate,
                    VerifiedStatus   = coverages.VerifiedStatus,
                    CreatedBy        = User.Identity.Name,
                    CreatedDate      = DateTime.Now
                };
            }
            else
            {
                tcoverage = new tblMbrCoverage()
                {
                    CoverageTypeID   = 999,
                    CoverageTypeName = "N/A",
                    IsActive         = false,
                    MrNumber         = mrNumber,
                    VerifiedByUser   = "******",
                    VerifiedDate     = DateTime.Now,
                    VerifiedStatus   = "N/A",
                    CreatedBy        = User.Identity.Name,
                    CreatedDate      = DateTime.Now
                };
            }
            using (var context = new lifeflightapps())
            {
                context.tblMbrCoverages.Add(tcoverage);
                context.SaveChanges();
                coverageId = tcoverage.MbrCoverageID;
            }
            return(coverageId);
        }
Exemplo n.º 11
0
 public ActionResult EditAgencyDetails(AgencyModel agency)
 {
     if (ModelState.IsValid)
     {
         tblEmsAgencyLocal dbAgencyLocal = new tblEmsAgencyLocal()
         {
             EMSID       = agency.AgencyId,
             Address     = agency.AddressLn1,
             Address2    = agency.AddressLn2,
             City        = agency.City,
             State       = agency.StateCode,
             Name        = agency.AgencyName,
             LocalUse    = agency.LocalUse,
             Type        = agency.AgencyType,
             Zip         = agency.Zip,
             County      = agency.County,
             Phones      = agency.Phone,
             BaseRate    = agency.BaseRate,
             MileageRate = agency.MileageRate,
             taxID       = agency.TaxId.ToString()
         };
         try
         {
             using (var context = new lifeflightapps())
             {
                 context.tblEmsAgencyLocals.AddOrUpdate(dbAgencyLocal);
                 context.SaveChanges();
             }
             return(RedirectToAction("GetAgencyDetails", new { agencyId = agency.AgencyId }));
         }
         catch (DataException dx)
         {
             ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
             throw dx;
         }
     }
     else
     {
         return(View(agency));
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Add contacts for the insurance agency
        /// </summary>
        /// <param name="InsuranceID"></param>
        /// <param name="Name"></param>
        /// <param name="Email"></param>
        /// <param name="Phone"></param>
        /// <param name="Fax"></param>
        /// <param name="Note"></param>
        /// <returns></returns>
        public JsonResult AddInsuranceContact(int InsuranceID, string Name, string Email, string Phone, string Fax, string Note)
        {
            tblInsuranceAgencyContact contact = new tblInsuranceAgencyContact()
            {
                InsuranceID  = InsuranceID,
                ContactName  = Name,
                ContactEmail = Email,
                ContactPhone = Phone,
                ContactFax   = Fax,
                ContactNote  = Note,
                CreatedBy    = User.Identity.Name,
                CreatedDate  = DateTime.Now
            };

            using (var context = new lifeflightapps())
            {
                context.tblInsuranceAgencyContacts.Add(contact);
                context.SaveChanges();
            }
            return(Json(JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="destinationType"></param>
        /// <param name="addressLineOne"></param>
        /// <param name="city"></param>
        /// <param name="state"></param>
        /// <param name="zip"></param>
        /// <returns></returns>
        private int DestinationEntry(string destinationType, string destinationName, string destinationInstructions, string addressLineOne, string city, string state, string zip, string phone, string travelTime, string miles)
        {
            int destinationId;
            int Miles = 0;

            if (!string.IsNullOrEmpty(miles))
            {
                if (miles.Contains("."))
                {
                    Miles = Convert.ToInt32(miles.Substring(0, miles.LastIndexOf(".")));
                }
                else
                {
                    Miles = Convert.ToInt32(miles);
                }
            }

            tblDischargeDestination tdestination = new tblDischargeDestination()
            {
                DestinationType  = destinationType,
                DestinationName  = destinationName,
                DestInstructions = destinationInstructions,
                AddressLineOne   = addressLineOne,
                City             = city,
                StateCode        = state,
                Zip        = zip,
                Miles      = Miles,
                Phone      = phone,
                TravelTime = Convert.ToDateTime(travelTime).TimeOfDay
            };

            using (var context = new lifeflightapps())
            {
                context.tblDischargeDestinations.Add(tdestination);
                context.SaveChanges();
                destinationId = tdestination.DestinationID;
            }
            return(destinationId);
        }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pickupNameToSave"></param>
        /// <param name="pickupInstructions"></param>
        /// <param name="pickupAddressLine1"></param>
        /// <param name="pickupCity"></param>
        /// <param name="pickupState"></param>
        /// <param name="pickupZip"></param>
        /// <param name="phone"></param>
        /// <returns></returns>
        private int PickupEntry(string pickupNameToSave, string pickupInstructions, string pickupAddressLine1, string pickupCity, string pickupState, string pickupZip, string phone)
        {
            int pickupId;
            tblDischargePickup tpickup = new tblDischargePickup()
            {
                PickupLocationName = pickupNameToSave,
                PickupInstructions = pickupInstructions,
                AddressLineOne     = pickupAddressLine1,
                City      = pickupCity,
                StateCode = pickupState,
                Zip       = pickupZip,
                Phone     = phone
            };

            using (var context = new lifeflightapps())
            {
                context.tblDischargePickups.Add(tpickup);
                context.SaveChanges();
                pickupId = tpickup.PickupID;
            }
            return(pickupId);
        }
Exemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="census"></param>
        /// <returns></returns>
        private int CensusEntry(CensusModel census, string mrNumber)
        {
            int         censusId;
            tblMbrCensu tcensus;

            if (census != null)
            {
                tcensus = new tblMbrCensu()
                {
                    Bed           = census.Bed,
                    MrNumber      = mrNumber,
                    PavillionCode = census.PavillionCode,
                    Unit          = census.Unit,
                    CreatedDate   = DateTime.Now,
                    CreatedBy     = User.Identity.Name
                };
            }
            else
            {
                tcensus = new tblMbrCensu()
                {
                    Bed           = "N/A",
                    MrNumber      = mrNumber,
                    PavillionCode = "N/A",
                    Unit          = "N/A",
                    CreatedDate   = DateTime.Now,
                    CreatedBy     = User.Identity.Name
                };
            }

            using (var context = new lifeflightapps())
            {
                context.tblMbrCensus.Add(tcensus);
                context.SaveChanges();
                censusId = tcensus.MbrCensusID;
            }
            return(censusId);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Add new insurance agency
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Description"></param>
        /// <param name="Phone"></param>
        /// <param name="Fax"></param>
        /// <param name="PreAuth"></param>
        /// <param name="OwnPaper"></param>
        /// <param name="Instructions"></param>
        /// <returns></returns>
        public JsonResult AddNewInsuranceAgency(string Name, string Description, string Phone, string Fax, bool PreAuth, bool OwnPaper, string Instructions)
        {
            int insuranceID = 0;

            using (var context = new lifeflightapps())
            {
                tblInsuranceAgency insAgency = new tblInsuranceAgency()
                {
                    INSAGENCYNAME   = Name,
                    DESCRIPTION     = Description,
                    INSURANCEPHONE  = Phone,
                    INSURANCEFAX    = Fax,
                    PREAUTHREQUIRED = PreAuth,
                    INSTRUCTIONS    = Instructions,
                    CREATEDBY       = User.Identity.Name,
                    CREATEDON       = DateTime.Now
                };
                context.tblInsuranceAgencies.Add(insAgency);
                context.SaveChanges();
                insuranceID = insAgency.INSURANCEID;
            }
            return(Json(insuranceID, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 17
0
 /// <summary>
 /// Remove the insurance xref EMS reference
 /// </summary>
 /// <param name="InsuranceId"></param>
 /// <param name="Agencies"></param>
 /// <returns></returns>
 public JsonResult RemoveInsAgencies(int InsuranceId, string[] Agencies)
 {
     string[] selectedAgencies = Agencies;
     foreach (var item in selectedAgencies)
     {
         //tblInsuranceEmsXref xref = new tblInsuranceEmsXref()
         //{
         //    Active = true,
         //    AgencyId = Convert.ToInt32(item),
         //    InsuranceProviderID = InsuranceId
         //};
         int agencyid = Convert.ToInt32(item);
         //tblInsuranceEmsXref xref = db.tblInsuranceEmsXrefs.Where(x => x.AgencyId == agencyid && x.InsuranceProviderID == InsuranceId).FirstOrDefault();
         using (var context = new lifeflightapps())
         {
             var xref = context.tblInsuranceEmsXrefs.Where(x => x.AgencyId == agencyid && x.InsuranceProviderID == InsuranceId).FirstOrDefault();
             context.tblInsuranceEmsXrefs.Attach(xref);
             context.tblInsuranceEmsXrefs.Remove(xref);
             context.SaveChanges();
         }
     }
     return(Json(JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 18
0
        public ActionResult AddAgency(AgencyModel agency)
        {
            if (string.IsNullOrEmpty(agency.AgencyName))
            {
                AgencyModel  model        = new AgencyModel();
                RequestModel requestModel = new RequestModel();
                model.StatesList = requestModel.GetStatesList().ToList();
                return(View(model));
            }
            else
            {
                using (var context = new lifeflightapps())
                {
                    tblEmsAgencyLocal emsAgency = new tblEmsAgencyLocal()
                    {
                        Name        = agency.AgencyName,
                        Address     = agency.AddressLn1,
                        City        = agency.City,
                        County      = agency.County,
                        State       = agency.StateCode,
                        Zip         = agency.Zip,
                        Phones      = agency.Phone,
                        LocalUse    = agency.LocalUse,
                        Type        = agency.AgencyType,
                        BaseRate    = agency.BaseRate,
                        MileageRate = agency.MileageRate,
                        Notes       = agency.Notes
                    };

                    context.tblEmsAgencyLocals.Add(emsAgency);
                    context.SaveChanges();
                    int id = emsAgency.EMSID;

                    return(RedirectToAction("GetAgencyDetails", new { agencyId = id }));
                }
            }
        }