public async Task <IActionResult> Edit(int id, [Bind("State_ID,State_Name")] State state)
        {
            if (HttpContext.Session.GetString("SessionID") == null)
            {
                return(RedirectToAction("Create", "Login"));
            }
            if (id != state.State_ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(state);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StateExists(state.State_ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(state));
        }
        public async Task <IActionResult> Edit(int id, [Bind("City_ID,State_ID,City_Name")] City city)
        {
            if (HttpContext.Session.GetString("SessionID") == null)
            {
                return(RedirectToAction("Create", "Login"));
            }
            if (id != city.City_ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                //loadDDL();
                try
                {
                    _context.Update(city);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CityExists(city.City_ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StateId"] = new SelectList(_context.STATETB, "State_ID", "State_Name");
            return(View(city));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit([Bind("Category_ID,Category_Name,Category_Description,Category_Profile,Category_SubDescription,Category_MainProfile")] Category category, IFormFile fileobj, IFormFile fileobj1, string fname, string fname1, int id)
        {
            if (HttpContext.Session.GetString("SessionID") == null)
            {
                return(RedirectToAction("Create", "Login"));
            }
            if (id != category.Category_ID)
            {
                return(NotFound());
            }

            var getimg = await _context.CATEGORYTB.FindAsync(id);

            _context.CATEGORYTB.Remove(getimg);
            fname = Path.Combine("wwwroot", "Category_Image", getimg.Category_Profile);
            FileInfo fi = new FileInfo(fname);

            if (fi.Exists)
            {
                System.IO.File.Delete(fname);
                fi.Delete();
            }

            fname1 = Path.Combine("wwwroot", "Category_Image", getimg.Category_MainProfile);
            FileInfo fi1 = new FileInfo(fname1);

            if (fi1.Exists)
            {
                System.IO.File.Delete(fname1);
                fi1.Delete();
            }

            var imgext = Path.GetExtension(fileobj.FileName);

            if (imgext == ".jpg" || imgext == ".png")
            {
                var uploadimg = Path.Combine("wwwroot", "Category_Image", fileobj.FileName);
                var stream    = new FileStream(uploadimg, FileMode.Create);
                await fileobj.CopyToAsync(stream);

                stream.Close();

                var uploadimg1 = Path.Combine("wwwroot", "Category_Image", fileobj1.FileName);
                var stream1    = new FileStream(uploadimg1, FileMode.Create);
                await fileobj1.CopyToAsync(stream1);

                stream1.Close();


                //mi.Medicine_ID = 1;
                category.Category_Profile     = fileobj.FileName;
                category.Category_MainProfile = fileobj1.FileName;
                _context.Update(category);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult ChangePassword(int id, Login model)
        {
            var item = _context.ADMINTB.Where(x => x.Admin_ID == id).First();

            item.Admin_Password = model.Admin_Password;
            _context.Update(item);
            _context.SaveChanges();

            ViewBag.AdminName = TempData["SessionName"];
            TempData.Keep("SessionName");
            ViewBag.AdminImg = TempData["SessionImg"];
            TempData.Keep("SessionImg");
            ViewBag.SID = TempData["Sessionid"];
            TempData.Keep("Sessionid");
            return(RedirectToAction("PasswordChangeMsg"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit([Bind("Medicine_ID,Medicine_Name,Medicine_Price,Medicine_Brand,Medicine_Strip_Tablets,Medicine_Image,Medicine_Content,Medicine_Description")] Medicine mi, IFormFile fileobj, string fname, int id)
        {
            if (id != mi.Medicine_ID)
            {
                return(NotFound());
            }
            else
            {
                var getimg = await _context.MEDICINETB.FindAsync(id);

                _context.MEDICINETB.Remove(getimg);
                fname = Path.Combine("wwwroot", "Medicine_Main_Image", getimg.Medicine_Image);
                FileInfo fi = new FileInfo(fname);
                if (fi.Exists)
                {
                    System.IO.File.Delete(fname);
                    fi.Delete();
                }
                var imgext = Path.GetExtension(fileobj.FileName);
                if (imgext == ".jpg" || imgext == ".png")
                {
                    var uploadimg = Path.Combine("wwwroot", "Medicine_Main_Image", fileobj.FileName);
                    var stream    = new FileStream(uploadimg, FileMode.Create);

                    await fileobj.CopyToAsync(stream);

                    stream.Close();

                    //mi.Medicine_ID = 1;
                    mi.Medicine_Image = fileobj.FileName;
                    _context.Update(mi);
                    await _context.SaveChangesAsync();
                }
            }



            //return View();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> ProfileEdit(int id, IFormFile fileobj, string fname, [Bind("Patient_ID,Patient_Name,Patient_Address,Patient_Contact,State_ID,City_ID,Patient_Email,Patient_Password,Patient_IsActive,Patient_Profile")] Patient patientReg)
        {
            if (HttpContext.Session.GetString("SessionID") == null)
            {
                return(RedirectToAction("Login", "PatientReg"));
            }
            var sessionid = (int)TempData["SessionID"];

            if (id != patientReg.Patient_ID)
            {
                TempData.Keep("SessionID");
                return(NotFound());
            }

            int SID      = Convert.ToInt32(Request.Form["State_ID"]);
            int CID      = Convert.ToInt32(Request.Form["City_ID"]);
            var pname    = Convert.ToString(Request.Form["pname"]);
            var paddress = Convert.ToString(Request.Form["paddress"]);
            var pcontact = Convert.ToString(Request.Form["pcontact"]);
            var pemail   = Convert.ToString(Request.Form["pemail"]);

            patientReg.State_ID        = SID;
            patientReg.City_ID         = CID;
            patientReg.Patient_Name    = pname;
            patientReg.Patient_Address = paddress;
            patientReg.Patient_Contact = pcontact;
            patientReg.Patient_Email   = pemail;
            if (patientReg.State_ID == 0)
            {
                ModelState.AddModelError("", "---Select State---");
            }
            else if (patientReg.City_ID == 0)
            {
                ModelState.AddModelError("", "---Select City---");
            }
            var          SubCategoryID = HttpContext.Request.Form["City_ID"].ToString();
            List <State> statelist     = new List <State>();

            statelist = (from state in _context.STATETB
                         select state).ToList();
            //statelist.Insert(0, new State { State_ID = 0, State_Name = "---Select State---" });
            ViewBag.ListofCategory = statelist;


            if (ModelState.IsValid)
            {
                var getimg = await _context.PATIENTTB.FindAsync(sessionid);

                _context.PATIENTTB.Remove(getimg);

                patientReg.Patient_Password = getimg.Patient_Password;
                patientReg.Patient_IsActive = getimg.Patient_IsActive;
                fname = Path.Combine("../Medical/wwwroot", "Patient_Image", getimg.Patient_Profile);
                FileInfo fi = new FileInfo(fname);
                if (fi.Exists)
                {
                    System.IO.File.Delete(fname);
                    fi.Delete();
                }
                var imgext = Path.GetExtension(fileobj.FileName);
                if (imgext == ".jpg" || imgext == ".png")
                {
                    var uploadimg = Path.Combine("../Medical/wwwroot", "Patient_Image", fileobj.FileName);
                    var stream    = new FileStream(uploadimg, FileMode.Create);

                    await fileobj.CopyToAsync(stream);

                    stream.Close();

                    var d = HttpContext.Session.GetInt32("SessionID");

                    patientReg.Patient_Profile = fileobj.FileName;
                    patientReg.Patient_ID      = sessionid;

                    _context.Update(patientReg);
                    await _context.SaveChangesAsync();
                }
            }
            TempData.Keep("SessionID");
            return(RedirectToAction("Profile", "PatientReg", new { id = TempData["SessionID"] }));
            //return RedirectToAction("Index","Home2");
        }