Esempio n. 1
0
        public ActionResult Create([Bind(Include = "FrameId,Mode,Name,AccountId,Mailbox,ShowEvents")] Outlook outlook, Frame frame)
        {
            if (!string.IsNullOrWhiteSpace(outlook.Mailbox))
            {
                Match lnk = _emailRgx.Match(outlook.Mailbox);
                outlook.Mailbox = lnk.Success ? lnk.Value : "";
            }

            if (ModelState.IsValid)
            {
                outlook.Frame = frame;
                db.Outlooks.Add(outlook);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.Outlook, outlook.Frame.TemplateId);
            FillModesSelectList(outlook.Mode);
            FillAccountsSelectList(outlook.AccountId);

            outlook.Frame = frame;

            return(View(outlook));
        }
        public ActionResult Attach(LocationSelector selector)
        {
            Frame frame = db.Frames.Find(selector.FrameId);

            if (frame == null)
            {
                return(View("Missing", new MissingItem(selector.FrameId)));
            }

            if (selector.LocationId > 0)
            {
                Location location = db.Locations.Find(selector.LocationId);
                if (location == null)
                {
                    return(View("Missing", new MissingItem(selector.LocationId, "Location")));
                }
                frame.Locations.Add(location);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            IEnumerable <Location> locations = db.Locations
                                               .Where(l => !db.Frames
                                                      .FirstOrDefault(f => f.FrameId == selector.FrameId)
                                                      .Locations.Any(fl => fl.LocationId == l.LocationId))
            ;

            ViewBag.Locations = new SelectList(db.Locations, "LocationId", "Name");

            return(View(selector));
        }
Esempio n. 3
0
        public ActionResult Create(Picture picture)
        {
            if (ModelState.IsValid)
            {
                if (picture.SavedContentId.HasValue)
                {
                    picture.ContentId = picture.SavedContentId.Value;
                    db.Frames.Add(picture);
                    db.SaveChanges();

                    return(RedirectToAction("Index", "Frame"));
                }
                else
                {
                    PushReferrer();

                    TempData["_newPicture"] = picture;
                    return(RedirectToAction("Upload", "Picture"));
                }
            }

            this.FillPanelsSelectList(db, picture.Panel.CanvasId, picture.PanelId);
            this.FillTemplatesSelectList(db, FrameTypes.Picture, picture.TemplateId);
            FillPicturesSelectList();
            FillModesSelectList();

            return(View(picture));
        }
        public ActionResult Create(Youtube youtube)
        {
            if (ModelState.IsValid)
            {
                Match lnk = _youTubeLink.Match(youtube.YoutubeId);
                if (lnk.Success)
                {
                    youtube.YoutubeId = lnk.Value;
                }

                db.Frames.Add(youtube);
                db.SaveChanges();

                return(RedirectToAction("Index", "Frame"));
            }

            this.FillPanelsSelectList(db, youtube.Panel.CanvasId, youtube.PanelId);
            this.FillTemplatesSelectList(db, FrameTypes.YouTube, youtube.TemplateId);
            FillAspectsSelectList();
            FillQualitySelectList();
            FillRatesSelectList();


            return(View(youtube));
        }
Esempio n. 5
0
        public ActionResult Create(Outlook outlook)
        {
            if (!string.IsNullOrWhiteSpace(outlook.Mailbox))
            {
                Match lnk = _emailRgx.Match(outlook.Mailbox);
                outlook.Mailbox = lnk.Success ? lnk.Value : "";
            }

            if (ModelState.IsValid)
            {
                db.Frames.Add(outlook);
                db.SaveChanges();

                return(RedirectToAction("Index", "Frame"));
            }

            this.FillPanelsSelectList(db, outlook.Panel.CanvasId, outlook.PanelId);
            this.FillTemplatesSelectList(db, FrameTypes.Outlook, outlook.TemplateId);
            FillModesSelectList(outlook.Mode);
            FillAccountsSelectList(outlook.AccountId);
            FillPrivacySelectList(outlook.Privacy);


            return(View(outlook));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "FrameId,Name,YoutubeId,Volume,AutoLoop,Aspect,Quality,Rate,Start")] Youtube youtube, Frame frame)
        {
            if (ModelState.IsValid)
            {
                Match lnk = _youTubeLink.Match(youtube.YoutubeId);
                if (lnk.Success)
                {
                    youtube.YoutubeId = lnk.Value;
                }

                youtube.Frame = frame;
                db.Youtube.Add(youtube);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.YouTube, youtube.Frame.TemplateId);
            FillAspectsSelectList();
            FillQualitySelectList();
            FillRatesSelectList();

            youtube.Frame = frame;

            return(View(youtube));
        }
Esempio n. 7
0
        public ActionResult Create(ReportServer reportserver)
        {
            if (ModelState.IsValid)
            {
                db.ReportServers.Add(reportserver);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(reportserver));
        }
Esempio n. 8
0
        public ActionResult Create(Level level)
        {
            if (ModelState.IsValid)
            {
                db.Levels.Add(level);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index"));
            }

            return(View(level));
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "TemplateId,Name,Html,FrameType,Version")] Template template)
        {
            if (ModelState.IsValid)
            {
                db.Templates.Add(template);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            FillFrameTypesSelectList(template.FrameType);
            return(View(template));
        }
        public ActionResult Create([Bind(Include = "Name,Provider,AppId,ClientId,ClientSecret")] OauthAccount account)
        {
            if (ModelState.IsValid)
            {
                db.OauthAccounts.Add(account);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            FillProviders(account.Provider);
            return(View(account));
        }
Esempio n. 11
0
        public ActionResult Upload(IEnumerable <HttpPostedFileBase> files)
        {
            // TODO: EditorFor

            bool hasFiles = false, addedFiles = false;

            foreach (HttpPostedFileBase file in files)
            {
                if (file != null && file.ContentLength > 0)
                {
                    string ext       = Path.GetExtension(file.FileName).Replace(".", "").ToUpper();
                    bool   isPicture = Picture.SupportedFormats.Contains(ext);
                    bool   isVideo   = Video.SupportedFormats.Contains(ext);

                    if (isPicture || isVideo)
                    {
                        byte[] buffer = null;
                        using (BinaryReader reader = new BinaryReader(file.InputStream))
                        {
                            buffer = reader.ReadBytes(file.ContentLength);
                        }

                        Content content = new Content {
                            Type = isPicture ? ContentTypes.ContentType_Picture : ContentTypes.ContentType_Video,
                            Name = Path.GetFileName(file.FileName),
                            Data = buffer,
                        };

                        db.Contents.Add(content);

                        addedFiles = true;
                    }

                    hasFiles = true;
                }
            }

            if (addedFiles)
            {
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index"));
            }

            else if (hasFiles)
            {
                // TODO: validator for wrong file types
            }

            return(View());
        }
Esempio n. 12
0
        public ActionResult Create(Canvas canvas)
        {
            if (ModelState.IsValid)
            {
                this.makeFullscreenPanel(canvas);
                db.Canvases.Add(canvas);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index"));
            }

            fillSelectBackgroundImage(canvas.BackgroundImage);
            return(View(canvas));
        }
Esempio n. 13
0
        public async Task <ActionResult> CreateAsync([Bind(Include = "Name,Resource,ClientId,ClientSecret,TenantId,User,PasswordUnmasked")] AzureAccount az)
        {
            await GetTokenAsync(az);

            if (ModelState.IsValid)
            {
                db.AzureAccounts.Add(az);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            FillResourceSelectList(az.Resource);
            return(View(az));
        }
Esempio n. 14
0
        public ActionResult Create(Panel panel)
        {
            if (ModelState.IsValid)
            {
                db.Panels.Add(panel);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            FillCanvasSelectList(panel.CanvasId);

            return(View(panel));
        }
Esempio n. 15
0
        public ActionResult Create(Memo memo)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(memo);
                db.SaveChanges();

                return(RedirectToAction("Index", "Frame"));
            }

            this.FillPanelsSelectList(db, memo.Panel.CanvasId, memo.PanelId);
            this.FillTemplatesSelectList(db, FrameTypes.Memo, memo.TemplateId);

            return(View(memo));
        }
Esempio n. 16
0
        public ActionResult Create(Display display)
        {
            if (ModelState.IsValid)
            {
                db.Displays.Add(display);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            FillCanvasSelectList(display.CanvasId);
            FillLocationSelectList(display.LocationId);

            return(View(display));
        }
Esempio n. 17
0
        public ActionResult Create(Memo memo)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(memo);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }


            this.FillTemplatesSelectList(db, FrameTypes.Memo, memo.TemplateId);

            return(View(memo));
        }
Esempio n. 18
0
        public ActionResult Create(Weather weather)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(weather);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.Weather, weather.TemplateId);
            FillWeatherTypeSelectList();


            return(View(weather));
        }
Esempio n. 19
0
        public ActionResult Create([Bind(Include = "FrameId,Name,Content")] Html html, Frame frame)
        {
            if (ModelState.IsValid)
            {
                html.Frame = frame;
                db.Html.Add(html);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            html.Frame = frame;

            this.FillTemplatesSelectList(db, FrameTypes.Html, frame.TemplateId);

            return(View(html));
        }
        public ActionResult Create(Weather weather)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(weather);
                db.SaveChanges();

                return(RedirectToAction("Index", "Frame"));
            }

            this.FillPanelsSelectList(db, weather.Panel.CanvasId, weather.PanelId);
            this.FillTemplatesSelectList(db, FrameTypes.Weather, weather.TemplateId);
            FillWeatherTypeSelectList();


            return(View(weather));
        }
Esempio n. 21
0
        public ActionResult Create(Clock clock)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(clock);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.Clock, clock.TemplateId);
            this.FillSystemTimeZoneSelectList(clock.TimeZone);
            FillClockTypeSelectList();


            return(View(clock));
        }
        public ActionResult Create(Powerbi powerbi)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(powerbi);
                db.SaveChanges();

                return(RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.Powerbi, powerbi.TemplateId);
            FillTypesSelectList(powerbi.Type);
            FillAccountsSelectList(powerbi.AccountId);


            return(View(powerbi));
        }
Esempio n. 23
0
        public ActionResult Create(Report report)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(report);
                db.SaveChanges();

                return(RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.Report, report.TemplateId);
            FillServersSelectList();
            FillModesSelectList();


            return(View(report));
        }
Esempio n. 24
0
        public ActionResult Create(Video video)
        {
            if (ModelState.IsValid)
            {
                if (video.SavedContentId.HasValue)
                {
                    Content content = db.Contents.Find(video.SavedContentId.Value);
                    video.Contents.Add(content);
                    db.Frames.Add(video);
                    db.SaveChanges();

                    return(RedirectToAction("Index", "Frame"));
                }
                else
                {
                    PushReferrer();

                    TempData["_newVideo"] = video;
                    return(RedirectToAction("Upload", "Video"));
                }
            }

            this.FillTemplatesSelectList(db, FrameTypes.Video, video.TemplateId);
            FillVideosSelectList();

            return(View(video));
        }
        public ActionResult Create(ReportServer reportserver)
        {
            if (!reportserver.PasswordSet)
            {
                ModelState.AddModelError("PasswordUnmasked", Resources.ProvideAccountPassword);
            }

            reportserver.UpdatePassword(db);

            if (ModelState.IsValid)
            {
                db.ReportServers.Add(reportserver);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(reportserver));
        }
        public ActionResult Create([Bind(Include = "Name,Account,PasswordUnmasked,Url,EwsVersion")] ExchangeAccount ews)
        {
            Match lnk = _emailRgx.Match(ews.Account);

            ews.Account = lnk.Success ? lnk.Value : "";

            resolveAccount(ews);

            if (ModelState.IsValid)
            {
                db.ExchangeAccounts.Add(ews);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            FillVersionsSelectList(ews.EwsVersion);
            return(View(ews));
        }
        public ActionResult Create(Html html)
        {
            if (ModelState.IsValid)
            {
                db.Frames.Add(html);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            html.Panel = db.Panels
                         .Include(p => p.Canvas)
                         .FirstOrDefault(p => p.PanelId == html.PanelId)
            ;

            this.FillTemplatesSelectList(db, FrameTypes.Html, html.TemplateId);

            return(View(html));
        }
Esempio n. 28
0
        public ActionResult Create(Report report, Frame frame)
        {
            if (ModelState.IsValid)
            {
                report.Frame = frame;
                db.Reports.Add(report);
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index", "Frame"));
            }

            this.FillTemplatesSelectList(db, FrameTypes.Report, report.Frame.TemplateId);
            FillServersSelectList();
            FillModesSelectList();

            report.Frame = frame;

            return(View(report));
        }
        public ActionResult Edit(Setting setting)
        {
            if (ModelState.IsValid)
            {
                db.Settings.Attach(setting);
                db.Entry(setting).Property(p => p.RawValue).IsModified = true;
                db.SaveChanges();

                return(this.RestoreReferrer() ?? RedirectToAction("Index"));
            }
            return(View(setting));
        }
        public ActionResult Create(Location location)
        {
            if (ModelState.IsValid)
            {
                // compute Woeid & GMT offset
                location.Woeid = GetDefaultWoeid(location.Latitude, location.Longitude);
                if (location.TimeZone == null)
                {
                    location.TimeZone = TimeZoneInfo.Local.Id; // GetDefaultTimeZone(location.Latitude, location.Longitude);
                }
                db.Locations.Add(location);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            FillLevelsSelectList(location.LevelId);
            FillTemperatureUnitSelectList(location.TemperatureUnit);
            FillAreaSelectList(location.LocationId, location.AreaId);
            FillCulturesSelectList(location.Culture);
            this.FillSystemTimeZoneSelectList(location.TimeZone);

            return(View(location));
        }