public EditBlogWebsite()
 {
     InitializeComponent();
     BindingContext                  = new BlogWebsite();
     SaveButton.IsEnabled            = false;
     TestActivityIndicator.IsEnabled = false;
     TestActivityIndicator.IsVisible = false;
     TestActivityIndicator.IsRunning = false;
 }
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            BlogWebsite blogWebsite = await db.BlogWebsites.FindAsync(id);

            db.BlogWebsites.Remove(blogWebsite);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Url,Logo,SchoolID")] BlogWebsite blogWebsite)
        {
            if (ModelState.IsValid)
            {
                db.Entry(blogWebsite).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.SchoolID = new SelectList(db.Schools, "ID", "Name", blogWebsite.SchoolID);
            return(View(blogWebsite));
        }
        // GET: BlogWebsites/Details/5
        public async Task <ActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogWebsite blogWebsite = await db.BlogWebsites.FindAsync(id);

            if (blogWebsite == null)
            {
                return(HttpNotFound());
            }
            return(View(blogWebsite));
        }
        // GET: BlogWebsites/Edit/5
        public async Task <ActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlogWebsite blogWebsite = await db.BlogWebsites.FindAsync(id);

            if (blogWebsite == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SchoolID = new SelectList(db.Schools, "ID", "Name", blogWebsite.SchoolID);
            return(View(blogWebsite));
        }
Example #6
0
        public static async Task InitializeSeedData()
        {
            var SampleBlogWebsites = new List <BlogWebsite>();
            var Website1           = new BlogWebsite
            {
                Name = "CCN",
                Url  = "https://ccn.com/"
            };
            var Website2 = new BlogWebsite
            {
                Name = "CryptoClarified",
                Url  = "https://cryptoclarified.com"
            };

            var Website3 = new BlogWebsite
            {
                Name = "Crypto Scoop",
                Url  = "http://cryptoscoop.net"
            };
            var Website4 = new BlogWebsite
            {
                Name = "Crypto Recorder",
                Url  = "https://cryptorecorder.com"
            };

            SampleBlogWebsites.Add(Website1);
            SampleBlogWebsites.Add(Website2);
            SampleBlogWebsites.Add(Website3);
            SampleBlogWebsites.Add(Website4);


            foreach (var sampleWebsite in SampleBlogWebsites)
            {
                var dbBlogWebsites = database.GetAllBlogWebsites();
                if (dbBlogWebsites.Count >= 4)
                {
                    return;
                }
                if (dbBlogWebsites.Find(x => x.Url == sampleWebsite.Url) == null)
                {
                    database.AddBlogWebsite(sampleWebsite);
                }
            }
        }
        public async Task <ActionResult> Create(BlogWebsite blogWebsite)
        {
            try
            {
                var blogWebsite1 = new BlogWebsite
                {
                    Id       = Guid.NewGuid(),
                    Name     = blogWebsite.Name,
                    Url      = blogWebsite.Url,
                    Logo     = blogWebsite.Logo,
                    SchoolID = blogWebsite.SchoolID
                };
                db.BlogWebsites.Add(blogWebsite1);
                db.SaveChanges();
            }

            catch (Exception e)
            {
                ModelState.AddModelError("", "Unable to save");
                return(View());
            }
            return(RedirectToAction("Index"));
        }
Example #8
0
 public int UpdateBlogWebsite(BlogWebsite blogWebsite)
 {
     return(database.Update(blogWebsite));
 }
Example #9
0
 public int AddBlogWebsite(BlogWebsite blogWebsite)
 {
     return(database.Insert(blogWebsite));
 }