Exemple #1
0
        public ActionResult Editaccount(User u, HttpPostedFileBase name)
        {
            Picture pic = new Picture();
            List<Picture> pc = new List<Picture>();

            byte[] array;
            if (name != null)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    name.InputStream.CopyTo(ms);
                    array = ms.GetBuffer();
                    pic.Pictures = array;

                    u.UserPicture.Pictures = array;

                    pm.savePicture(pic);

                }
            }
            int id=pm.GetAll().Max(p=>p.PictureId);
            u.UserPicture.PictureId = id;
               // u.PictureId = id;

            um.EditUser(u);
            return View("View1");
        }
Exemple #2
0
 public void SavePicture(Picture picture)
 {
     // throw new NotImplementedException();
     this.repo.Create(picture);
 }
        public ActionResult Create(Programm p, HttpPostedFileBase PatientPhoto, HttpPostedFileBase PatientVideo, HttpPostedFileBase MedicalAdviceDocumentPath, HttpPostedFileBase DoctorRecommendationDocumentPath, HttpPostedFileBase MedicalConditionDocumentPath, int CityID, int StateID, int CountryID)
        {
            // Request.Files["PatientPhoto"]
            List<Country> countries = locmng.GetAllCountries();
            ViewBag.countrylist = new SelectList(countries.OrderBy(c => c.Name), "CountryID", "Name");
            List<City> citylist = locmng.GetAllCities();
            ViewBag.cities = new SelectList(citylist, "CityID", "Name");
            City cc = new City();
            State ss = new State();
            Country cs = new Country();
            cc.CityID = CityID;
            ss.StateID = StateID;
            cs.CountryID = CountryID;
            p.Address.City = cc;
            p.Address.City.State = ss;
            p.Address.City.State.Country = cs;

            try
            {
                string fileExt = Path.GetExtension(PatientPhoto.FileName);
                switch (fileExt.ToLower())
                {
                    case ".jpg": break;
                    case ".png": break;
                    case ".jpeg": break;
                    case ".gif": break;

                    default:

                        ViewBag.Message1 = "File type must be of the type .jpeg,.jif,.png,.jpg";
                        return View("Create");

                }
            }
            catch (NullReferenceException e)
            {

                ViewBag.Message = "Sorry! no file can be  uploaded";
            }

            try
            {
                string fileExt1 = Path.GetExtension(MedicalAdviceDocumentPath.FileName);
                switch (fileExt1.ToLower())
                {
                    case ".doc": break;
                    case ".pdf": break;
                    case ".txt": break;
                    default:
                        ViewBag.Message2 = "File type must be of the type .doc,.pdf,.txt";
                        return View("List");
                }
            }
            catch (NullReferenceException e)
            {

                ViewBag.Message = "Sorry! no file can be  uploaded";
            }

            try
            {
                string fileExt2 = Path.GetExtension(DoctorRecommendationDocumentPath.FileName);
                switch (fileExt2.ToLower())
                {
                    case ".doc": break;
                    case ".pdf": break;
                    case ".txt": break;
                    default:
                        ViewBag.Message3 = "File type must be of the type .doc,.pdf..txt";
                        return View("Create");
                }
            }
            catch (NullReferenceException e)
            {

                ViewBag.Message = "Sorry! no file can be  uploaded";
            }

            try
            {
                string fileExt3 = Path.GetExtension(MedicalConditionDocumentPath.FileName);
                switch (fileExt3.ToLower())
                {
                    case ".doc": break;
                    case ".pdf": break;
                    case ".txt": break;
                    default:
                        ViewBag.Message4 = "The path File type must be of the type .doc,.pdf..txt";
                        return View("Create");
                }
            }
            catch (NullReferenceException e)
            {

                ViewBag.Message = "Sorry! no file can be  uploaded";
            }

            Picture pic = new Picture();
            List<Picture> pc = new List<Picture>();
            Patient patient = new Patient();

            PatientMedicalDetail pmd = new PatientMedicalDetail();
            PatientMedicalDetail pmd1 = new PatientMedicalDetail();
            PatientMedicalDetail pmd2 = new PatientMedicalDetail();
            byte[] array;
            //byte[] array1;
            byte[] array2;
            byte[] array3;
            byte[] array4;

            using (MemoryStream ms = new MemoryStream())
            {
                PatientPhoto.InputStream.CopyTo(ms);
                array = ms.GetBuffer();
                pic.Pictures = array;
                // pic.Pictures = array;
                //pc.Add(pic);

                p.Pictures = pic;
            }

            //using (MemoryStream ms1 = new MemoryStream())
            //{
            //    PatientVideo.InputStream.CopyTo(ms1);
            //    array1 = ms1.GetBuffer();
            //    patient.VideoFilePath = array1;
            //    p.Patient.VideoFilePath = array1;

            //}

            using (MemoryStream ms2 = new MemoryStream())
            {
                MedicalAdviceDocumentPath.InputStream.CopyTo(ms2);
                array2 = ms2.GetBuffer();
                pmd.MedicalAdviceDocument = array2;
                p.PatientMedicalDetail.MedicalAdviceDocument = array2;
            }

            using (MemoryStream ms3 = new MemoryStream())
            {
                DoctorRecommendationDocumentPath.InputStream.CopyTo(ms3);
                array3 = ms3.GetBuffer();
                pmd1.DoctorRecommendationDocument = array3;
                p.PatientMedicalDetail.DoctorRecommendationDocument = array3;
            }

            using (MemoryStream ms4 = new MemoryStream())
            {
                MedicalConditionDocumentPath.InputStream.CopyTo(ms4);
                array4 = ms4.GetBuffer();
                pmd2.MedicalAdviceDocument = array4;
                p.PatientMedicalDetail.MedicalConditionDocument = array4;
            }

            if (PatientPhoto == null)
            {
                p.Pictures = null;
            }

            if (PatientVideo == null)
            {
                p.Patient.VideoFilePath = null;
            }

            if (MedicalAdviceDocumentPath == null)
            {
                p.PatientMedicalDetail.MedicalAdviceDocument = null;
            }

            if (DoctorRecommendationDocumentPath == null)
            {
                p.PatientMedicalDetail.DoctorRecommendationDocument = null;
            }

            if (MedicalConditionDocumentPath == null)
            {
                p.PatientMedicalDetail.MedicalConditionDocument = null;
            }

            pm.SaveProgram(p);
            return View("CreateSuccess");
        }