示例#1
0
        public async Task <IActionResult> Edit(IFormFile fileobj, [Bind("Doctor_ID,Doctor_Name,Doctor_Email,Doctor_Gender,Doctor_Password,Doctor_Contact,Doctor_IsActive,Category_ID,Doctor_Degree,Doctor_Profile,Doctor_Experience,Doctor_Education")] DoctorReg doctorReg, string fname, int id)
        {
            var getimg = await _context.DOCTORTB.FindAsync(id);

            _context.DOCTORTB.Remove(getimg);
            fname = Path.Combine("../Medical/wwwroot", "Doctor_Image", getimg.Doctor_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", "Doctor_Image", fileobj.FileName);
                var stream    = new FileStream(uploadimg, FileMode.Create);

                await fileobj.CopyToAsync(stream);

                stream.Close();

                var Pass = HttpContext.Session.GetString("SessionPassword");
                //mi.Medicine_ID = 1;
                doctorReg.Doctor_Profile  = fileobj.FileName;
                doctorReg.Doctor_IsActive = false;
                doctorReg.Doctor_Password = Pass;
                _context.Update(doctorReg);
                await _context.SaveChangesAsync();
            }

            ViewBag.DoctorName = TempData["SessionName"];
            TempData.Keep("SessionName");
            ViewBag.DoctorImg = TempData["SessionImg"];
            TempData.Keep("SessionImg");
            ViewBag.SID = TempData["Sessionid"];
            TempData.Keep("Sessionid");
            TempData.Keep("CountAppo");
            TempData.Keep("CountPat");
            TempData.Keep("CountReview");
            return(RedirectToAction("Index", "Home1"));
        }
示例#2
0
        public async Task <TEntity> UpdateAsync(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
            }

            try
            {
                DoctorContext.Update(entity);
                await DoctorContext.SaveChangesAsync();

                return(entity);
            }
            catch (Exception ex)
            {
                throw new Exception($"{nameof(entity)} could not be updated {ex.Message}");
            }
        }
示例#3
0
        public async Task <IActionResult> Edit(IFormFile fileobj, [Bind("Clinic_ID,Clinic_Name,Clinic_Address,Clinic_Pincode,Clinic_Contact,Clinic_IsActive,Clinic_Profile,State_ID,City_ID,Doctor_ID")] DocClinic clinic, string fname, int id)
        {
            if (clinic.State_ID == 0)
            {
                ModelState.AddModelError("", "---Select State---");
            }
            else if (clinic.City_ID == 0)
            {
                ModelState.AddModelError("", "---Select City---");
            }


            // ------- Getting selected Value ------- //
            var SubCategoryID = HttpContext.Request.Form["City_ID"].ToString();


            // ------- Setting Data back to ViewBag after Posting Form ------- //
            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---" });
            //-------Assigning categorylist to ViewBag.ListofCategory------//
            ViewBag.ListofCategory = statelist;



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

            _context.CLINICTB.Remove(getimg);
            fname = Path.Combine("../Medical/wwwroot", "Clinic_Images", getimg.Clinic_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", "Clinic_Images", fileobj.FileName);
                var stream    = new FileStream(uploadimg, FileMode.Create);

                await fileobj.CopyToAsync(stream);

                stream.Close();

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

                //mi.Medicine_ID = 1;
                clinic.Clinic_Profile  = fileobj.FileName;
                clinic.Clinic_IsActive = false;
                clinic.Doctor_ID       = (int)d;

                _context.Update(clinic);
                await _context.SaveChangesAsync();
            }


            ViewBag.DoctorName = TempData["SessionName"];
            TempData.Keep("SessionName");
            ViewBag.DoctorImg = TempData["SessionImg"];
            TempData.Keep("SessionImg");
            ViewBag.SID = TempData["Sessionid"];
            TempData.Keep("Sessionid");
            return(RedirectToAction("Index"));
        }