public ActionResult Create([Bind(Include = "ID,Number,ProfileID,AstroID")] RatingAstro ratingAstro)
        {
            try
            {
                ratingAstro.Astro = db.Astroes
                                    .Where(a => a.ID == ratingAstro.AstroID).FirstOrDefault();
                if (ModelState.IsValid)
                {
                    ratingAstro.Profile = db.Profiles
                                          .Where(p => p.UserName == User.Identity.Name).FirstOrDefault();


                    db.RatingAstroes.Add(ratingAstro);
                    db.SaveChanges();
                    var routeValue = new RouteValueDictionary
                                         (new { action = "Details", controller = "Astro", id = ratingAstro.AstroID });
                    return(RedirectToRoute(routeValue));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(ratingAstro));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            RatingAstro ratingAstro = db.RatingAstroes.Find(id);

            db.RatingAstroes.Remove(ratingAstro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Number,ProfileID,AstroID")] RatingAstro ratingAstro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ratingAstro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AstroID   = new SelectList(db.Astroes, "ID", "Name", ratingAstro.AstroID);
     ViewBag.ProfileID = new SelectList(db.Profiles, "Id", "UserName", ratingAstro.ProfileID);
     return(View(ratingAstro));
 }
        // GET: RatingAstro/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RatingAstro ratingAstro = db.RatingAstroes.Find(id);

            if (ratingAstro == null)
            {
                return(HttpNotFound());
            }
            return(View(ratingAstro));
        }
        // GET: RatingAstro/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RatingAstro ratingAstro = db.RatingAstroes.Find(id);

            if (ratingAstro == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AstroID   = new SelectList(db.Astroes, "ID", "Name", ratingAstro.AstroID);
            ViewBag.ProfileID = new SelectList(db.Profiles, "Id", "UserName", ratingAstro.ProfileID);
            return(View(ratingAstro));
        }