public ActionResult Create([Bind(Include = "AddressID,StreetNumber,StreetName,City,State,PostalCode,CustomerID,ProviderID")] Address address)
        {
            if (ModelState.IsValid)
            {
                string id       = User.Identity.GetUserId();                                                   //saves currently logged in user id to string id
                bool?  provider = (from pr in db.AspNetUsers where pr.Id == id select pr.IsProvider).Single(); //finds currently logged in user and checks if they are a provider or not then...
                if ((bool)provider)
                {
                    address.ProviderID = (from p in db.Providers where p.UserName == id select p.ProviderID).First(); //if they are a provider, it finds their provider id in the database and saves it as the provider id in the addresses table
                }
                else
                {
                    address.CustomerID = (from c in db.Customers where c.UserName == id select c.CustomerID).First(); //if they are not a provider, it finds the customer id in the databse and saves it as the customer id in the addresses table
                }
                db.Addresses.Add(address);
                db.SaveChanges();
                if ((bool)provider)
                {
                    return(RedirectToAction("Details", "Providers", new { id = address.ProviderID }));
                }
                else
                {
                    return(RedirectToAction("Details", "Customers", new { id = address.CustomerID }));
                }
            }

            return(View(address));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "ImageID,ImageBin,ImageIMG,CustomerID,ProviderID")] ImagesTwo imagesTwo, HttpPostedFileBase image1, int?id)
        {
            if (ModelState.IsValid)
            {
                imagesTwo.ImageBin = new byte[image1.ContentLength];
                image1.InputStream.Read(imagesTwo.ImageBin, 0, image1.ContentLength);
                imagesTwo.ProviderID = id;
                //string id = User.Identity.GetUserId(); //saves currently logged in user id to string id
                //bool? provider = (from pr in db.AspNetUsers where pr.Id == id select pr.IsProvider).First(); //finds currently logged in user and checks if they are a provider or not then...
                //if ((bool)provider)
                //{
                //    imagesTwo.ProviderID = (from p in db.Providers where p.UserName == id select p.ProviderID).First(); //if they are a provider, it finds their provider id in the database and saves it as the provider id in the addresses table
                //}
                //else
                //{
                //    imagesTwo.CustomerID = (from c in db.Customers where c.UserName == id select c.CustomerID).First(); //if they are not a provider, it finds the customer id in the databse and saves it as the customer id in the addresses table
                //}
                db.ImagesTwoes.Add(imagesTwo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CustomerName", imagesTwo.CustomerID);
            ViewBag.ProviderID = new SelectList(db.Providers, "ProviderID", "ProviderName", imagesTwo.ProviderID);
            return(View(imagesTwo));
        }
        public ActionResult Create([Bind(Include = "ProviderID,ProviderName,ProviderPhone,ProviderEmail,UserName,Title,Description,Active,IsSnow, Services")] Provider provider)
        {
            if (ModelState.IsValid)
            {
                db.Providers.Add(provider);
                db.SaveChanges();
                return(RedirectToAction("Create", "Addresses"));
            }

            ViewBag.UserName = new SelectList(db.AspNetUsers, "Id", "Email", provider.UserName);
            return(View(provider));
        }
        public ActionResult Create([Bind(Include = "ChatID,Message,ChatDate,IsRead,CustomerID,ProviderID")] Chat chat)
        {
            if (ModelState.IsValid)
            {
                db.Chats.Add(chat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CustomerName", chat.CustomerID);
            ViewBag.ProviderID = new SelectList(db.Providers, "ProviderID", "ProviderName", chat.ProviderID);
            return(View(chat));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "CustomerID,CustomerName,CustomerPhone,CustomerEmail,UserName")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                customer.UserName      = User.Identity.GetUserId();
                customer.CustomerEmail = User.Identity.Name;
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Create", "Addresses"));
            }

            ViewBag.UserName = new SelectList(db.AspNetUsers, "Id", "Email", customer.UserName);
            return(View(customer));
        }
        public ActionResult Add(FormCollection form)
        {
            var comment   = form["Comment"].ToString();
            var articleId = int.Parse(form["ArticleId"]);
            var rating    = int.Parse(form["Rating"]);

            ArticlesComment artComment = new ArticlesComment()
            {
                ProviderID   = articleId,
                Comments     = comment,
                Rating       = rating,
                ThisDateTime = DateTime.Now
            };

            db.ArticlesComments.Add(artComment);
            db.SaveChanges();

            return(RedirectToAction("Details", "Providers", new { id = articleId }));
        }