Beispiel #1
0
        public IActionResult Update(ConsultViewModel consVM)
        {
            // Check eerst de standaard fouten:
            if (!ModelState.IsValid)
            {
                return(View(consVM));
            }

            // Check hier de velden op complexere correcte invoer
            // Stop met valideren bij de eerste gevonden fout

            string errMsg = ErrorCheck.CheckForErrors(consVM);

            if (errMsg != null) // Specifieke, complexe fout gevonden
            {
                ModelState.AddModelError(string.Empty, errMsg);
                return(View(consVM));
            }

            // converteer pW5LinesVM naar PrescrWithLine via extension method
            var cons = consVM.ToCons();

            _consultManager.Upd(cons);

            return(RedirectToAction("Index",
                                    new
            {
                doctorId = cons.DoctorId,
                clientId = cons.ClientId
            }));
        }
Beispiel #2
0
        //[Authorize(User.Identity.IsAuthenticated =true)]
        public ActionResult Consult(int?page, int?spage)
        {
            string           UID   = User.Identity.GetUserId();
            ConsultViewModel model = new ConsultViewModel(page, spage, UID);

            //var DataContext = new ApplicationDbContext();

            if (spage == null)
            {
                ViewBag.liclass1  = "active text-content";
                ViewBag.tabclass1 = "tab-pane fade in active ";
                ViewBag.liclass2  = "text-content";
                ViewBag.tabclass2 = "tab-pane fade";
            }
            else
            {
                ViewBag.liclass1  = "text-content";
                ViewBag.tabclass1 = "tab-pane fade";
                ViewBag.liclass2  = "active text-content";
                ViewBag.tabclass2 = "tab-pane fade in active";
            }

            Bar = 0;
            ViewBag.FileCount = Bar;

            return(View(model));
        }
        public ActionResult ConsulterNotes(int id)
        {
            ConsultViewModel vm = new ConsultViewModel();

            vm.Eleve = dbContext.Eleves.SingleOrDefault(e => e.Id == id);
            //var notes  =
            vm.Notes = vm.Eleve.Notes.ToList();
            return(View(vm));
        }
Beispiel #4
0
        // -----------------------------------------------------------------------------------------------------------------
        // GET voor Delete

        public IActionResult Delete(int consId)
        {
            var cons = _consultManager.Get(consId);

            var consVM = new ConsultViewModel
            {
                ClientFullName = _clientManager.ClientFullName(cons.ClientId),
                DoctorFullName = _clientManager.DoctorFullName(cons.DoctorId),
                Consult        = cons
            };

            return(View(consVM));
        }
Beispiel #5
0
        // Update - GET ---------------------------------------------------------------------------------------
        public IActionResult Update(int consId)
        {
            var cons = _consultManager.Get(consId);

            // Maak viewmodel voor 1 Consult, inclusief
            // FullName van client en dokter

            // Algemene velden:
            var ConsVM = new ConsultViewModel
            {
                ClientFullName = _clientManager.ClientFullName(cons.ClientId),
                DoctorFullName = _clientManager.DoctorFullName(cons.DoctorId),
                Consult        = cons
            };

            return(View(ConsVM));
        }
        //------------------------------------------------------------------------------

        internal static Consult ToCons(this ConsultViewModel consVM)
        {
            // Map only fields 1:1 from ViewModel to Model
            var result = new Consult
            {
                Id               = consVM.Consult.Id,
                ActionCode       = consVM.Consult.ActionCode,
                ClientId         = consVM.Consult.ClientId,
                DoctorId         = consVM.Consult.DoctorId,
                ConsultDate      = consVM.Consult.ConsultDate,
                ConsultDescr     = consVM.Consult.ConsultDescr,
                Price            = consVM.Consult.Price,
                CommentForDoctor = consVM.Consult.CommentForDoctor
            };

            return(result);
        }
Beispiel #7
0
        // -----------------------------------------------------------------------------------------------------------------
        // GET voor Details

        public IActionResult Details(int consId)
        {
            // De consultManager maakt een nieuw object in de heap van class Consult aan
            // cons wijst naar dit object.
            var cons = _consultManager.Get(consId);

            // Maak viewmodel voor 1 Consult, inclusief
            // FullName van client en dokter

            var consVM = new ConsultViewModel
            {
                ClientFullName = _clientManager.ClientFullName(cons.ClientId),
                DoctorFullName = _clientManager.DoctorFullName(cons.DoctorId),
                Consult        = cons
            };

            return(View(consVM));
        }
Beispiel #8
0
        public ActionResult Details(int?id)
        {
            if (id != null)
            {
                using (IDal dal = new Dal())
                {
                    Consultation cons = dal.GetConsultationById((int)id);
                    if (cons != null)
                    {
                        ConsultViewModel cvm = new ConsultViewModel(cons);
                        return(View(cvm));
                    }

                    return(HttpNotFound());
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
Beispiel #9
0
        public IActionResult Create(ConsultViewModel consVM)
        {
            if (!ModelState.IsValid)
            {
                // Geef de ViewModel terug:

                // Opmerking: onderstaande werkt niet.
                // "Descr is CHANGED" komt niet in het scherm.
                // Je kan bij return View(xxx) geen nieuwe veldwaarden meegeven
                consVM.Consult.ConsultDescr = "Descr is CHANGED";

                // Het viewmodel moet altijd in de return, ook al doet het scherm er niets mee
                // Het scherm verwacht altijd deze VM, zowel bij de Get als bij de Post
                return(View(consVM));
            }

            // Check hier de velden op correcte invoer (complexer)
            // Stop met valideren bij de eerste gevonden fout

            // Opmerking: als je spaties invult in een Line, wordt dit
            // als een NULL string terug aan deze POST ACTION Method teruggegeven
            string errMsg = ErrorCheck.CheckForErrors(consVM);

            if (errMsg != null) // Specifieke fout gevonden
            {
                ModelState.AddModelError(string.Empty, errMsg);

                // VM moet altijd in de return, ook al doet het scherm er niets mee
                // Het scherm verwacht altijd deze VM, zowel bij de Get als bij de Create
                return(View(consVM));
            }

            var cons = consVM.ToCons();

            _consultManager.Add(cons);

            return(RedirectToAction("Index",
                                    new
            {
                doctorId = consVM.Consult.DoctorId,
                clientId = consVM.Consult.ClientId
            }));
        }
Beispiel #10
0
        // -----------------------------------------------------------------------------------------------------------------
        // Create GET

        public IActionResult Create(int doctorId, int clientId)
        // Een consult kan alleen worden gecreëerd als zowel de arts
        // als de client bekend is.
        {
            var consVM = new ConsultViewModel();

            consVM.ClientFullName = _clientManager.ClientFullName(clientId);
            consVM.DoctorFullName = _clientManager.DoctorFullName(doctorId);

            // Vergeet onderstaande regel niet,
            // Immers de Create View moet 2 hidden fields krijgen voor clientId en doctorId
            // Zo niet, dan zijn deze 2 sleutelwaarden verloren bij inkomende VM voor de POST CREATE
            consVM.Consult = new Consult {
                ClientId = clientId, DoctorId = doctorId
            };
            consVM.Consult.ConsultDate = DateTime.Now; // Zet de datum alvast op vandaag

            return(View(consVM));
        }
Beispiel #11
0
        internal static string CheckForErrors(ConsultViewModel consVM)
        {
            bool fmtOK;

            fmtOK = CheckFmt(consVM.Consult.ConsultDescr, patternGeneral);
            if (!fmtOK)
            {
                return("Formaat \'Consult Omschrijving\' is incorrect");
            }


            // Controleer dat de datum niet in de toekomst is
            if (consVM.Consult.ConsultDate > DateTime.Today)
            {
                return($"Datum consult is nu: \' {consVM.Consult.ConsultDate} \'- kan niet in de toekomst zijn");
            }

            return(null);
        }
Beispiel #12
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Consult(ConsultViewModel model, string btnSubmit, IEnumerable <HttpPostedFileBase> uploads)
        {
            ViewBag.liclass1  = "active text-content";
            ViewBag.tabclass1 = "tab-pane fade in active ";
            ViewBag.liclass2  = "text-content";
            ViewBag.tabclass2 = "tab-pane fade";

            var    DataContext = new ApplicationDbContext();
            string CUid        = User.Identity.GetUserId();

            model.crntConsultations = DataContext.Enquirys.Where(e => e.ExpRpDate != null & e.Noter.Id.Equals(CUid) & e.AnswerToCustomer == null).AsEnumerable().OrderBy(e => e.ExpRpDate).ToPagedList(1, 5);
            model.pastConsultations = DataContext.Enquirys.Where(e => e.ExpRpDate != null & e.Noter.Id.Equals(CUid) & e.AnswerToCustomer != null).AsEnumerable().OrderBy(e => e.ExpRpDate).ToPagedList(1, 5);

            if (false)//!ModelState.IsValid
            {
                ViewBag.Message = "Please provide all the required information !";
                return(View(model));
                //return Content(uploads.Any().ToString());
            }
            else
            {
                //Create an Enquiry Record:
                ApplicationUser current = DataContext.Users.Find(CUid);

                Enquiry consult = new Enquiry(model.techEqry.Title, current)
                {
                    ExpRpDate   = model.techEqry.ExpRpDate,
                    Qdetail     = model.techEqry.Qdetail,
                    Product     = model.techEqry.Product,
                    Service     = model.techEqry.Service,
                    Destination = model.techEqry.Destination,
                    cvoting     = new Vote(),
                };

                //Files(Attachments) upload:
                consult.FilePaths = new List <FilePath>();
                foreach (var upload in uploads)
                {
                    if (upload != null && upload.ContentLength > 0)
                    {
                        string ext      = Path.GetExtension(upload.FileName).ToLower();
                        string mimeType = "application/unknown";
                        Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
                        if (regKey != null && regKey.GetValue("Content Type") != null)
                        {
                            mimeType = regKey.GetValue("Content Type").ToString();
                        }

                        var PictureExtensions = new[] { ".png", ".jpg", ".gif", ".jpeg" };
                        var showType          = FileType.Tex;
                        if (PictureExtensions.Contains(ext))
                        {
                            showType = FileType.Ref;
                        }


                        var file = new FilePath
                        {
                            FileName     = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(upload.FileName),
                            OrgnFileName = System.IO.Path.GetFileName(upload.FileName),
                            FileType     = showType,
                            ContentType  = mimeType
                        };

                        consult.FilePaths.Add(file);

                        try
                        {
                            string path = Path.Combine(Server.MapPath("~/Images"),
                                                       Path.GetFileName(file.FileName));
                            upload.SaveAs(path);
                            ViewBag.Message = "File uploaded successfully";
                        }
                        catch (Exception ex)
                        {
                            ViewBag.Message = "ERROR:" + ex.Message.ToString();
                            return(Content(ViewBag.Message));
                        }
                    }
                }

                /*
                 * if (model.File != null&&model.File.ContentLength>0)
                 * {
                 *  byte[] uploadedFile = new byte[model.File.InputStream.Length];
                 *  model.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);
                 *  consult.File = uploadedFile;
                 * }*/
                DataContext.Enquirys.Add(consult);

                DataContext.SaveChanges();

                switch (btnSubmit)
                {
                case "Consult Experts":

                    //Call Experts:
                    Group TT = new Group();
                    TT.Participants = new List <ApplicationUser>();
                    foreach (string uid in model.CallExpert)
                    {
                        var call = DataContext.Users.Find(uid);

                        if (call != null)
                        {
                            //consult.ExpertAnswer.DcnGroup.Participants.Add(call);
                            TT.Participants.Add(call);
                        }
                    }
                    TT.Participants.Add(current);

                    consult.ExpertAnswer = new Answer()
                    {
                        sendTime   = (DateTime)model.techEqry.ExpRpDate,
                        DcnGroup   = TT,
                        dcsnStatus = "on",
                        dsnbgntime = DateTime.Now
                    };
                    DataContext.SaveChanges();
                    ViewBag.Status = "Successfully Submit. Assignees shall reply to you in 2 days ! ";
                    break;

                case "Consult TechKnowTeam":
                default:

                    //create TKT discussion:
                    Group TKT = DataContext.Groups.Find(24);
                    TKT.Participants.Add(current);
                    consult.ExpertAnswer = new Answer()
                    {
                        sendTime   = (DateTime)model.techEqry.ExpRpDate,
                        DcnGroup   = TKT,
                        dcsnStatus = "on",
                        dsnbgntime = DateTime.Now
                    };

                    DataContext.SaveChanges();

                    ViewBag.Status = "Successfully Submit. TechKnowTeam shall reply to you in 2 days ! ";
                    break;
                }

                return(View(model));
            }
            //There is a bug of titles showing, still do not know why
        }
Beispiel #13
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Share(ConsultViewModel model, IEnumerable <HttpPostedFileBase> uploads)
        {
            //Show current consultations:
            ViewBag.liclass1  = "active text-content";
            ViewBag.tabclass1 = "tab-pane fade in active ";
            ViewBag.liclass2  = "text-content";
            ViewBag.tabclass2 = "tab-pane fade";

            ApplicationDbContext addEnqNote = new ApplicationDbContext();
            var uid = User.Identity.GetUserId();

            model.crntConsultations = addEnqNote.Enquirys.Where(e => e.ExpRpDate != null & e.Noter.Id.Equals(uid) & e.AnswerToCustomer == null).AsEnumerable().OrderBy(e => e.ExpRpDate).ToPagedList(1, 5);
            model.pastConsultations = addEnqNote.Enquirys.Where(e => e.ExpRpDate != null & e.Noter.Id.Equals(uid) & e.AnswerToCustomer != null).AsEnumerable().OrderBy(e => e.ExpRpDate).ToPagedList(1, 5);


            //The flow:
            if (!ModelState.IsValid || model.techEqry.AnswerToCustomer == null || model.techEqry.BssResult == null)
            {
                ViewBag.massage = "Check the required Fields !";
                return(Content("Works"));
                //return View(model);
            }

            ApplicationUser current = addEnqNote.Users.Find(uid);
            Enquiry         note    = new Enquiry(model.techEqry.Title, model.techEqry.AnswerToCustomer, current)
            {
                BssResult = model.techEqry.BssResult,//Useless?

                Product     = model.techEqry.Product,
                Service     = model.techEqry.Service,
                Destination = model.techEqry.Destination,
                Qdetail     = model.techEqry.Qdetail,
                cvoting     = new Vote(),
            };

            //Files(Attachments) upload:
            note.FilePaths = new List <FilePath>();
            foreach (var upload in uploads)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    string ext      = Path.GetExtension(upload.FileName).ToLower();
                    string mimeType = "application/unknown";
                    Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
                    if (regKey != null && regKey.GetValue("Content Type") != null)
                    {
                        mimeType = regKey.GetValue("Content Type").ToString();
                    }

                    var PictureExtensions = new[] { ".png", ".jpg", ".gif", ".jpeg" };
                    var showType          = FileType.Tex;
                    if (PictureExtensions.Contains(ext))
                    {
                        showType = FileType.Ref;
                    }


                    var file = new FilePath
                    {
                        FileName     = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(upload.FileName),
                        OrgnFileName = System.IO.Path.GetFileName(upload.FileName),
                        FileType     = showType,
                        ContentType  = mimeType
                    };

                    note.FilePaths.Add(file);

                    try
                    {
                        string path = Path.Combine(Server.MapPath("~/Images"),
                                                   Path.GetFileName(file.FileName));
                        upload.SaveAs(path);
                        ViewBag.Message = "File uploaded successfully";
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message = "ERROR:" + ex.Message.ToString();
                        return(Content(ViewBag.Message));
                    }
                }
            }

            addEnqNote.Enquirys.Add(note);
            addEnqNote.SaveChanges();

            //return RedirectToAction("Index");
            ViewBag.Status = "Successfully Submit !";
            return(View("Consult", model));
        }