public ActionResult Create(List <AppointmentResultCreateViewModel> model, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            foreach (var item in model)
            {
                var result = new AppointmentResult
                {
                    AppoitmentId = Convert.ToInt32(item.AppoitmentId),
                    PriceId      = item.PriceId,
                    Count        = item.Count
                };
                AppResult.Create(result);
            }

            var app = Appointment.GetById(Convert.ToInt32(model[0].AppoitmentId));

            app.AppointmentStatus = Status.Completed;
            Appointment.Update(app);



            return(RedirectToLocal(redirectUrl));
        }
Exemplo n.º 2
0
        // get from stream
        static public UInt32 get(mln.EndianStream rEs, out AppointmentResult rOut)
        {
            UInt32 ret = 0;

            rEs.get(out ret);
            rOut = (AppointmentResult)ret;
            return(4);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            AppointmentResult appointmentResult = await db.AppointmentResults.FindAsync(id);

            db.AppointmentResults.Remove(appointmentResult);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Recommendations,AppointmentId,Sintomas,Date")] AppointmentResult appointmentResult)
        {
            if (ModelState.IsValid)
            {
                db.Entry(appointmentResult).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.AppointmentId = new SelectList(db.Appointments, "Id", "Comments", appointmentResult.AppointmentId);
            return(View(appointmentResult));
        }
Exemplo n.º 5
0
        // convert id to string
        static public string AppointmentResultToString(AppointmentResult v)
        {
            switch (v)
            {
            case AppointmentResult.APPOINTMENTRESULT_SUCCESS: return("APPOINTMENTRESULT_SUCCESS");

            case AppointmentResult.APPOINTMENTRESULT_FAILURE: return("APPOINTMENTRESULT_FAILURE");

            case AppointmentResult.APPOINTMENTRESULT_FAILURE_EMPTY_NOT_FOUND: return("APPOINTMENTRESULT_FAILURE_EMPTY_NOT_FOUND");
            }
            return("unknown");
        }
Exemplo n.º 6
0
        public async Task <AppointmentResult> GetAppointmentById(Guid id)
        {
            Appointment appointment = await _appointmentReadOnlyRepository.GetById(id);

            if (appointment == null)
            {
                throw new AppointmentNotFoundException($"The appointment {id} does not exists.");
            }

            AppointmentResult appointmentResult = new AppointmentResult(appointment);

            return(appointmentResult);
        }
Exemplo n.º 7
0
        public async Task <IEnumerable <AppointmentResult> > GetAllAppointments()
        {
            IEnumerable <Appointment> appointments = await _appointmentReadOnlyRepository.GetAll();

            List <AppointmentResult> appointmentResults = new List <AppointmentResult>();

            foreach (Appointment appointment in appointments)
            {
                AppointmentResult appointmentResult = new AppointmentResult(appointment);
                appointmentResults.Add(appointmentResult);
            }

            return(appointmentResults);
        }
        // GET: AppointmentResults/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AppointmentResult appointmentResult = await db.AppointmentResults.FindAsync(id);

            if (appointmentResult == null)
            {
                return(HttpNotFound());
            }
            return(View(appointmentResult));
        }
        // GET: AppointmentResults/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AppointmentResult appointmentResult = await db.AppointmentResults.FindAsync(id);

            if (appointmentResult == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AppointmentId = new SelectList(db.Appointments, "Id", "Comments", appointmentResult.AppointmentId);
            return(View(appointmentResult));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Post([FromBody]  Appointment appointment)
        {
            if (ModelState.IsValid)
            {
                //Run check to make sure there are no conflicting appointments

                AppointmentResult appointmentResult = await _requestAppointment.CreateAppointment(
                    appointment.AppointmentType, appointment.RequestDate,
                    appointment.ClientId, appointment.PatientId);

                await _hubContext.Clients.All.SendAsync("ReceiveAppointment", appointmentResult);

                return(Ok());
            }

            return(BadRequest(ModelState));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> PutAppointment(int id, Appointment appt)
        {
            if (id != appt.Id)
            {
                return(BadRequest("No request exists with that ID."));
            }

            // Validation: make sure date is in format yyyy-MM-dd
            Regex rgx = new Regex(@"(^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$)");

            if (rgx.IsMatch(appt.Date))
            {
                // Validation: only one appointment can be at a location per day
                foreach (Appointment apptMade in _context.Appointments)
                {
                    if (appt.Date.Equals(apptMade.Date) && appt.CenterId == apptMade.CenterId)
                    {
                        return(BadRequest("An appointment at center " + apptMade.CenterId + " on " + apptMade.Date + " exists."));
                    }
                }

                _context.Entry(appt).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                // Create an Appointment Result object with the same information, but load in the center, using the ID from the appt added
                AppointmentResult result = _resultContext.AppointmentResults.Single(r => r.Id == id);
                result.Date           = appt.Date;
                result.ClientFullName = appt.ClientFullName;
                _resultContext.Entry(result).State = EntityState.Modified;

                await _resultContext.SaveChangesAsync();
            }
            else
            {
                return(BadRequest("Date is not in correct format. Please Re-Enter in the format: \"yyyy-MM-dd\"."));
            }

            return(NoContent());
        }
Exemplo n.º 12
0
        public async Task <AppointmentResult> CreateAppointment(string appointmentType, DateTime requestDate, Guid clientId, Guid patientId)
        {
            bool clientExists = await _clientReadOnlyRepository.ExistsById(clientId);

            if (!clientExists)
            {
                throw new ClientNotFoundException($"The client {clientId} does not exists.");
            }

            bool patientExists = await _patientReadOnlyRepository.ExistsById(patientId);

            if (!patientExists)
            {
                throw new PatientNotFoundException($"The patient {patientId} does not exists.");
            }


            Appointment appointment = new Appointment(appointmentType, requestDate, clientId, patientId);

            AppointmentResult aptResult = new AppointmentResult(appointment);

            return(aptResult);
        }
Exemplo n.º 13
0
        public async Task <ActionResult <Appointment> > PostTodoItem(Appointment appt)
        {
            // Validation: make sure date is in format yyyy-MM-dd
            Regex rgx = new Regex(@"(^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$)");

            if (rgx.IsMatch(appt.Date))
            {
                // Validation: only one appointment can be at a location per day
                foreach (Appointment apptMade in _context.Appointments)
                {
                    if (appt.Date.Equals(apptMade.Date) && appt.CenterId == apptMade.CenterId)
                    {
                        return(BadRequest("An appointment at center " + apptMade.CenterId + " on " + apptMade.Date + " exists."));
                    }
                }
                _context.Appointments.Add(appt);
                await _context.SaveChangesAsync();

                // Create an Appointment Result object with the same information, but load in the center, using the ID from the appt added
                AppointmentResult result = new AppointmentResult
                {
                    Id             = appt.Id,
                    Date           = appt.Date,
                    ClientFullName = appt.ClientFullName,
                    Center         = null
                };
                _resultContext.AppointmentResults.Add(result);

                await _resultContext.SaveChangesAsync();

                return(Ok("Appointment created with ID " + appt.Id));
            }
            else
            {
                return(BadRequest("Date is not in correct format. Please Re-Enter in the format: \"yyyy-MM-dd\"."));
            }
        }
Exemplo n.º 14
0
 public AppointmentResult AddOrUpdate(ApiHeader apiHeader, AppointmentResult entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 15
0
 // set in stream
 public static UInt32 set( mln.EndianStream rEs, AppointmentResult rIn )
 {
     rEs.put((UInt32)rIn);
     return 4;
 }
Exemplo n.º 16
0
 // get from stream
 public static UInt32 get( mln.EndianStream rEs, out AppointmentResult rOut )
 {
     UInt32 ret=0;
     rEs.get( out ret );
     rOut = (AppointmentResult)ret;
     return 4;
 }
Exemplo n.º 17
0
 // convert id to string
 public static string AppointmentResultToString( AppointmentResult v )
 {
     switch(v){
     case AppointmentResult.APPOINTMENTRESULT_SUCCESS : return "APPOINTMENTRESULT_SUCCESS";
     case AppointmentResult.APPOINTMENTRESULT_FAILURE : return "APPOINTMENTRESULT_FAILURE";
     case AppointmentResult.APPOINTMENTRESULT_FAILURE_EMPTY_NOT_FOUND : return "APPOINTMENTRESULT_FAILURE_EMPTY_NOT_FOUND";
     }
     return "unknown";
 }
Exemplo n.º 18
0
 // set in stream
 static public UInt32 set(mln.EndianStream rEs, AppointmentResult rIn)
 {
     rEs.put((UInt32)rIn);
     return(4);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Gets the DiaryAppointment from DB for a DiaryAppointmentID
        /// </summary>
        /// <param name="AppointmentID">DiaryAppointmentID</param>
        /// <returns>true/false</returns>
        public bool GetAppointmentbyID(int AppointmentID)
        {
            bool diaryResult = false;
            AppointmentResult result = new AppointmentResult();

            AquariumDiaryManagement.SessionDetails sd = SDKHelper.GetSessionDetails<AquariumDiaryManagement.SessionDetails>("User");
            result = DiarySdk.GetAppointment(sd, AppointmentID);
            if (result.ResultInfo.ReturnCode == AquariumDiaryManagement.BasicCode.OK)
            {
                diaryResult = true;
                Appointments = new List<DiaryAppointment>();
                ReminderValues = new List<string>();

                GetAllLeads();
                GetAllUsers();
                GetAllTimeshiftValues();

                Appointments.Add(ToDiaryAppointment(result.Appointment));
                Reminders = result.Reminders.ToList();

                int leadTypeID = this.GetLeadTypeIDbyLeadID((int)Appointments[0].LeadID);
                if (Appointments[0].DiaryAppointmentTitle.Contains("\n"))
                    this.GetDiaryTitlebyTitle(Appointments[0].DiaryAppointmentTitle.Replace("\n", string.Empty));
                else
                    this.GetDiaryTitlebyTitle(Appointments[0].DiaryAppointmentTitle);

                if (Appointments[0].DiaryAppointmentText.Contains("\n"))
                    this.GetDiaryTextbyText(Appointments[0].DiaryAppointmentText.Replace("\n", string.Empty), leadTypeID, DiaryTitles.DiaryTitleID);
                else
                    this.GetDiaryTextbyText(Appointments[0].DiaryAppointmentText, leadTypeID, DiaryTitles.DiaryTitleID);

                Appointments[0].DiaryAppointmentText = DiaryTexts.DiaryTextID.ToString();
                Appointments[0].DiaryAppointmentTitle = DiaryTitles.DiaryTitleID.ToString();

                DiaryPriorityLink dpl = new DiaryPriorityLink();

                dpl.GetPriorityLinkbyID(AppointmentID);

                DiaryPriority dp = new DiaryPriority();
                dp.GetDiaryPriority(dpl.DiaryPriorityID);
                dp.GetAllDiaryPriorities();

                DiaryPriorities = new List<DiaryPriority>();
                DiaryPriorities.Add(dp);

                GetAllDiaryTitles();
                GetDefaultDiaryText();

                if (Reminders.Count == 0)
                    Reminders.Add(new Reminder { ClientPersonnelID = Appointments[0].CreatedBy, DiaryReminderID = 0 });
            }
            else if (result.ResultInfo.ReturnCode == AquariumDiaryManagement.BasicCode.Failed)
            {
                throw new System.ApplicationException("Error ID:" + result.ResultInfo.Errors[0].ResultCodeID + ", Description:" + result.ResultInfo.Errors[0].Description);
            }
            return diaryResult;
        }