Exemple #1
0
        public ActionResult Create([Bind(Include = "ID,BusinessName1,Logo,Email,Website,BusinessType_id,Branch_id")] BusinessName businessName, HttpPostedFileBase Logo)
        {
            string newname   = "";
            string extention = Path.GetExtension(Logo.FileName);

            newname = DateTime.Now.Ticks.ToString() + extention;
            var mypath = Path.Combine(Server.MapPath("~/Logoimg"), newname);

            Logo.SaveAs(mypath);
            if (ModelState.IsValid)
            {
                businessName.Logo = newname;

                db.BusinessName.Add(businessName);
                if (db.SaveChanges() > 0)
                {
                    TempData["success"] = "success add business";
                }
                else
                {
                    TempData["error"] = "not add yet";
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.Branch_id       = new SelectList(db.Branch, "ID", "Branchname", businessName.Branch_id);
            ViewBag.BusinessType_id = new SelectList(db.BusinessType, "ID", "BusinessType1", businessName.BusinessType_id);
            return(View(businessName));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "City_id,name,Latitude,Longitude,Country_id")] Cities cities)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(cities);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Country_id = new SelectList(db.Countries, "Country_ID", "name", cities.Country_id);
            return(View(cities));
        }
        public ActionResult Create([Bind(Include = "ID,Branchname,Address,Phone,City_id,Country_id")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branch.Add(branch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.City_id    = new SelectList(db.Cities, "City_id", "name", branch.City_id);
            ViewBag.Country_id = new SelectList(db.Countries, "Country_ID", "name", branch.Country_id);
            return(View(branch));
        }
        public ActionResult Create_business(BusinessType info, HttpPostedFileBase Photo)
        {
            string newname   = "";
            string extention = Path.GetExtension(Photo.FileName);

            newname = DateTime.Now.Ticks.ToString() + extention;
            var mypath = Path.Combine(Server.MapPath("~/businessImg"), newname);

            Photo.SaveAs(mypath);
            if (ModelState.IsValid)
            {
                info.Photo = newname;
                db.BusinessType.Add(info);
                if (db.SaveChanges() > 0)
                {
                    TempData["success"] = "success add businesstype";
                }
                else
                {
                    TempData["error"] = "not add yet";
                }
            }
            else
            {
                TempData["error"] = "Check Some Errors";
            }

            return(RedirectToAction("Create_business"));
        }
Exemple #5
0
        public ActionResult Create_country(Countries info, HttpPostedFileBase flag)
        {
            string newname   = "";
            string extention = Path.GetExtension(flag.FileName);

            newname = DateTime.Now.Ticks.ToString() + extention;
            var mypath = Path.Combine(Server.MapPath("~/FlagImg"), newname);

            flag.SaveAs(mypath);
            if (ModelState.IsValid)
            {
                info.flag = newname;
                db.Countries.Add(info);
                if (db.SaveChanges() > 0)
                {
                    TempData["success"] = "success add country";
                }
                else
                {
                    TempData["error"] = "not add yet";
                }
            }
            else
            {
                TempData["error"] = "Check Some Errors";
            }

            return(RedirectToAction("Create_country"));
        }