Пример #1
0
        public BaseController()
        {
            _settings = _settingRepository.GetById(1);

            ViewBag.SiteTitle          = _settings.Title;
            ViewBag.TitleColor         = _settings.TitleColor;
            ViewBag.TitleSize          = _settings.TitleSize;
            ViewBag.IntroText          = _settings.IntroText;
            ViewBag.IntroTextColor     = _settings.IntroTextColor;
            ViewBag.IntroTextSize      = _settings.IntroTextSize;
            ViewBag.InfoText           = _settings.InfoText;
            ViewBag.BackgroundImageUrl = _settings.BackgroundImageUrl;
        }
Пример #2
0
        public ActionResult Edit(int id)
        {
            var settings = _settingRepository.GetById(1);

            var imagesFolder = System.Configuration.ConfigurationManager.AppSettings["ImagesFolder"];
            var physicalDir  = System.Web.HttpContext.Current.Server.MapPath(imagesFolder);
            var images       = Directory.GetFiles(physicalDir);
            var imageUrls    = new List <string>();

            foreach (var image in images)
            {
                imageUrls.Add(imagesFolder + @"/" + Path.GetFileName(image));
            }

            var viewModel = new SettingViewModel()
            {
                Id                 = settings.Id,
                Title              = settings.Title,
                TitleColor         = settings.TitleColor,
                TitleSize          = settings.TitleSize,
                IntroText          = settings.IntroText,
                IntroTextColor     = settings.IntroTextColor,
                IntroTextSize      = settings.IntroTextSize,
                InfoText           = settings.InfoText,
                EmailDisclaimer    = settings.EmailDisclaimer,
                BackgroundImageUrl = settings.BackgroundImageUrl,
                MaxFileSize        = 512,
                AcceptFileTypes    = @"/(\.|\/)(jpg)$/i",
                UploadUrl          = "/api/upload/image",
                Images             = imageUrls,
                LegacyAmount       = settings.LegacyPeriod.Amount,
                LegacyUnit         = settings.LegacyPeriod.Unit,
                LegacyText         = settings.LegacyText
            };

            return(View(viewModel));
        }
Пример #3
0
        public IHttpActionResult Create([FromBody] RegistrationViewModel data)
        {
            try
            {
                var eventItem = _eventRepository.GetById(data.EventId);

                var visitor = _visitorRepository.GetByEmail(data.Email);
                if (visitor == null)
                {
                    visitor = Visitor.Create(data.Name, data.City, data.Email, data.Postcode);
                    _visitorRepository.Insert(visitor);
                }

                var numberOfVisitors = Convert.ToInt32(data.NumberOfVisitors);

                var registration = Registration.Create(visitor, eventItem, numberOfVisitors, false);
                registration.Confirmed        = true;
                registration.ConfirmationDate = DateTime.Now;

                _registrationRepository.Insert(registration);

                var logoUrl    = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/img";
                var barcodeUrl = @"https://chart.googleapis.com/chart?chl=" + Uri.EscapeUriString(registration.Id.ToString()) + @"&chs=200x200&cht=qr&chld=H%7C0";

                var settings = _settingRepository.GetById(1);

                ConfirmationEmail email = new ConfirmationEmail()
                {
                    To               = visitor.Email,
                    Name             = visitor.Name,
                    Date             = eventItem.TimeRange.Start.ToString("dd-MM-yyyy"),
                    TimeFrom         = eventItem.TimeRange.Start.ToShortTimeString(),
                    TimeTill         = eventItem.TimeRange.End.ToShortTimeString(),
                    NumberOfVisitors = registration.NumberOfVisitors,
                    LogoUrl          = logoUrl,
                    BarcodeUrl       = barcodeUrl,
                    RegistrationId   = registration.Id.ToString(),
                    Disclaimer       = settings.EmailDisclaimer,
                };

                email.Send();

                return(Ok(new { message = "Registratie is verzonden en bevestigd" }));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Пример #4
0
        public void GetSettings()
        {
            var rep = new SettingRepository();

            var settings = rep.GetById(1);
        }
Пример #5
0
 public SettingDto GetById(string id)
 {
     return(MapperHelper <Setting, SettingDto> .ConvertToDto(_repository.GetById(id)));
 }