コード例 #1
0
        public IActionResult Update(Guid id)
        {
            try
            {
                var user = _userManager.GetUserAsync(User).Result;
                if (!_companyManager.IsUserCompanyAdmin(user.Id, id))
                {
                    return(NotFound());
                }

                var company = _companyManager.Get(id);
                if (company == null)
                {
                    return(NotFound());
                }

                var model = new OrganizationViewModel(company)
                {
                    Countries = _countryManager.GetCountries()
                                .Select(c => new SelectListItem
                    {
                        Text  = c.Name,
                        Value = c.IsoCountryCode
                    }).ToList()
                };

                return(View(nameof(Update), model));
            }
            catch (InvalidOperationException e)
            {
                _logger.LogError(e.Message, e);
                return(NotFound());
            }
        }
コード例 #2
0
        public IActionResult BookingForm(int id, int?persons)
        {
            var formModel = new BookingFormViewModel();

            Accommodation accommodation;

            try
            {
                accommodation               = _accommodationManager.GetAccommodation(id);
                formModel.AccommodationId   = accommodation.Id;
                formModel.AccommodationName = accommodation.Name;
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }

            formModel.Persons = new List <BookingPerson>();

            //If an amount of persons was given, use it.
            //Otherwise, get the maximum persons from the Accommodation.
            int maxPersons;

            if (persons.HasValue && persons.Value <= accommodation.MaxPersons)
            {
                maxPersons = persons.Value;
            }
            else
            {
                maxPersons = accommodation.MaxPersons;
            }

            ViewBag.MaxPersons = maxPersons;

            //Initialize BookingPersons for the form
            for (int i = 0; i < accommodation.MaxPersons; i++)
            {
                formModel.Persons.Add(new BookingPerson());
            }

            //Get countries from db
            var countries = _countryManager.GetCountries();

            ViewBag.Countries = countries;

            //Get client API key
            ViewBag.MapApiKey = _mapService.GetApiKey();

            return(View("BookingForm", formModel));
        }
コード例 #3
0
 public EditWindow()
 {
     InitializeComponent();
     policyManager  = new PolicyManager();
     quoteManager   = new QuoteManager();
     countryManager = new CountryManager();
     countriesList  = countryManager.GetCountries();
 }
コード例 #4
0
 public NewQuote()
 {
     InitializeComponent();
     quote          = new Quote();
     quoteManager   = new QuoteManager();
     countryManager = new CountryManager();
     countriesList  = countryManager.GetCountries();
     DataContext    = this;
 }
コード例 #5
0
 public NewPolicy()
 {
     InitializeComponent();
     policy         = new Policy();
     policyManager  = new PolicyManager();
     countryManager = new CountryManager();
     countriesList  = countryManager.GetCountries();
     DataContext    = this;
 }
コード例 #6
0
        public IActionResult Get()
        {
            IEnumerable <Country> countries = countryManager.GetCountries();

            //Generate a list of HALResponses
            var response = new List <HALResponse>();

            foreach (Country country in countries)
            {
                response.Add(
                    new HALResponse(country)
                    .AddLinks(new Link[] {
                    new Link(Link.RelForSelf, $"/api/v1/countries/{country.Id}"),
                    new Link("updateCountry", $"/api/v1/countries/{country.Id}", "Update Country", "PUT"),
                    new Link("deleteCountry", $"/api/v1/countries/{country.Id}", "Delete Country", "DELETE")
                })
                    );
            }

            return(this.Ok(response));
        }
コード例 #7
0
        public IHttpActionResult ImportCountries()
        {
            var countries = _countryManager.GetCountries <Country>(CountryApiConstants.AllCountries);
            IList <Db.Country> countriesToSave = Mapper.Map <IList <Country>, IList <Db.Country> >(countries);

            if (Repository.Countries.Any())
            {
                Repository.Countries.AddRange(countriesToSave);
                Repository.SaveChanges();
                return(Ok(Repository.Countries));
            }

            return(Ok(countries));
        }
コード例 #8
0
        public EditWindow(string type, object context)
        {
            InitializeComponent();
            policyManager          = new PolicyManager();
            quoteManager           = new QuoteManager();
            countryManager         = new CountryManager();
            countriesList          = countryManager.GetCountries();
            cb_Country.ItemsSource = countriesList;

            _viewType = type;
            try
            {
                if (_viewType == ConfigurationManager.AppSettings["VIEW_TYPE_POLICY"])
                {
                    int _policyId = (int)context;
                    _policy            = policyManager.GetPolicy(_policyId);
                    txtb_header.Text   = "Editing Policy : " + _policy.Id.ToString();
                    txt_Firstname.Text = _policy.InsurerFirstName;
                    txt_Lastname.Text  = _policy.InsurerLastName;
                    //txt_Middlename.Text = _policy.InsurerMiddleName;
                    txt_Email.Text       = _policy.Email;
                    txt_PhoneNumber.Text = _policy.Phone;
                    txt_TotalAmount.Text = _policy.Amount.ToString();
                    txt_Address.Text     = _policy.Address;
                    txt_State.Text       = _policy.State;

                    txt_Pincode.Text = _policy.Pin.ToString();
                    //txt_AccountNumber.Text = _policy.BankAccountNumber;
                    txt_AgentName.Text          = _policy.AgentName;
                    txt_Nominee.Text            = _policy.Nominee;
                    txt_Relation.Text           = _policy.Relation;
                    date_StartDate.SelectedDate = _policy.StartDate;
                    date_EndDate.SelectedDate   = _policy.EndDate;

                    if (_policy.Gender == "MALE")
                    {
                        rbm.IsChecked = true;
                    }
                    else if (_policy.Gender == "FEMALE")
                    {
                        rbf.IsChecked = true;
                    }
                    else
                    {
                        rbo.IsChecked = true;
                    }
                }
                else if (_viewType == ConfigurationManager.AppSettings["VIEW_TYPE_QUOTE"])
                {
                    int _quoteId = (int)context;
                    _quote = quoteManager.GetQuote(_quoteId);
                    btn_UploadFile.Visibility = Visibility.Hidden;
                    txtb_header.Text          = "Editing Quote : " + _quote.Id.ToString();
                    txt_Firstname.Text        = _quote.InsurerFirstName;
                    txt_Lastname.Text         = _quote.InsurerLastName;
                    //txt_Middlename.Text = _quote.InsurerMiddleName;
                    txt_Email.Text       = _quote.Email;
                    txt_PhoneNumber.Text = _quote.Phone;
                    txt_TotalAmount.Text = _quote.Amount.ToString();
                    txt_Address.Text     = _quote.Address;
                    txt_State.Text       = _quote.State;

                    txt_Pincode.Text = _quote.Pin.ToString();
                    //txt_AccountNumber.Text = _quote.BankAccountNumber;
                    txt_AgentName.Text = _quote.AgentName;
                    txt_Nominee.Text   = _quote.Nominee;
                    txt_Relation.Text  = _quote.Relation;

                    date_StartDate.SelectedDate = _quote.StartDate;
                    date_EndDate.SelectedDate   = _quote.EndDate;

                    if (_quote.Gender == "MALE")
                    {
                        rbm.IsChecked = true;
                    }
                    else if (_quote.Gender == "FEMALE")
                    {
                        rbf.IsChecked = true;
                    }
                    else
                    {
                        rbo.IsChecked = true;
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #9
0
        public ViewWindow(string type, object context)
        {
            InitializeComponent();
            countryManager = new CountryManager();
            policyManager  = new PolicyManager();
            quoteManager   = new QuoteManager();
            _viewType      = type;

            try
            {
                if (_viewType == ConfigurationManager.AppSettings["VIEW_TYPE_POLICY"])
                {
                    int policyId = (int)context;
                    _policy                  = policyManager.GetPolicy(policyId);
                    _policy.Country          = countryManager.GetCountries().Find(x => x.Code == _policy.Country).Description;
                    _policy.Type             = GetPolicyOrQuoteTypes(_policy.Type);
                    _policy.AddressProofType = _policy.AddressProofType == "PASS" ? "Passport" : "Voter id";
                    this.txtb_header.Text    = "Policy ID :" + _policy.Id.ToString();

                    if (_policy.Gender == "MALE")
                    {
                        txt_Gender.Text = "MALE";
                    }
                    else if (_policy.Gender == "FEMALE")
                    {
                        txt_Gender.Text = "FEMALE";
                    }
                    else
                    {
                        txt_Gender.Text = "OTHERS";
                    }

                    this.DataContext = _policy;
                }
                else if (_viewType == ConfigurationManager.AppSettings["VIEW_TYPE_QUOTE"])
                {
                    int quoteId = (int)context;
                    _quote                  = quoteManager.GetQuote(quoteId);
                    _quote.Country          = countryManager.GetCountries().Find(x => x.Code == _quote.Country).Description;
                    _quote.Type             = GetPolicyOrQuoteTypes(_quote.Type);
                    _quote.AddressProofType = _quote.AddressProofType == "PASS" ? "Passport" : "Voter id";
                    this.txtb_header.Text   = "Quote ID :" + _quote.Id.ToString();
                    this.btn_DownloadDocument.Visibility = Visibility.Collapsed;

                    if (_quote.Gender == "MALE")
                    {
                        txt_Gender.Text = "MALE";
                    }
                    else if (_quote.Gender == "FEMALE")
                    {
                        txt_Gender.Text = "FEMALE";
                    }
                    else
                    {
                        txt_Gender.Text = "OTHERS";
                    }

                    this.DataContext = _quote;
                }
                else
                {
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #10
0
 public async Task <IActionResult> Get()
 {
     return(await Task.Run <IActionResult>(() => new OkObjectResult(new GenericResponseMessage <IEnumerable <CountryBo> >(_countryManager.GetCountries()
                                                                                                                          .OrderByDescending(c => c.IsoCountryCode == "US")
                                                                                                                          .ThenBy(c => c.Name)))));
 }