Exemplo n.º 1
0
        public ActionResult VASetting(string caseNumber)
        {
            Boolean isNumber = Regex.IsMatch(caseNumber, @"^\d+$");

            if (isNumber == false)
            {
                return(Json(new { Result = "Fail, maximum case can only contain numeric character" }));
            }
            Clinic clinic = _VCRepo.Get();

            clinic.maximumCase = Int32.Parse(caseNumber.ToString());
            _VCRepo.Update(clinic);

            List <AppointmentTimeSlot> appTimeblock = _AppTimeRepo.GetAll().ToList();

            if (appTimeblock != null && appTimeblock.Count > 0)
            {
                foreach (var apptime in appTimeblock)
                {
                    //Update Timeblock (2)
                    TimeSlot updateTimeBlock = _TimeSlotRepo.GetByID(apptime.timeId);
                    int      id = apptime.appointmentID;

                    // 2.2 update status
                    if (updateTimeBlock.numberofCase < clinic.maximumCase)
                    {
                        if (updateTimeBlock.numberofCase == 1 && updateTimeBlock.status == "Full")
                        {
                            // not up date --> still Full
                        }
                        else
                        {
                            updateTimeBlock.status = "Free";
                            _TimeSlotRepo.Update(updateTimeBlock);
                        }
                    }
                    else
                    {
                        if (updateTimeBlock.numberofCase == 1 && updateTimeBlock.status == "Full")
                        {
                            // not up date --> still Full
                        }
                        else
                        {
                            updateTimeBlock.status = "Busy";
                            _TimeSlotRepo.Update(updateTimeBlock);
                        }
                    }
                }
            }


            return(Json(new { Result = "Success" }));
        }
        public ActionResult Delete(int memberid)
        {
            // Clinic object
            Clinic clinic = _VCRepo.Get();

            /*delte appointment first*/
            IEnumerable <Appointment> memApp = _AppRepo.GetByMemberId(memberid);

            if (memApp != null && memApp.Count() > 0)
            {
                foreach (var app in memApp)
                {   /*But first, remove appointment from time slot*/
                    // Check for time slot of each appointment
                    IEnumerable <AppointmentTimeSlot> appTimeblock = _AppTimeRepo.GetByAppointmentID(app.id);
                    if (appTimeblock != null && appTimeblock.Count() > 0)
                    {
                        foreach (var apptime in appTimeblock)
                        {
                            //Update Timeblock (2)
                            TimeSlot updateTimeBlock = _TimeSlotRepo.GetByID(apptime.timeId);
                            // 2.1 reduce number of case
                            updateTimeBlock.numberofCase -= 1;

                            // 2.2 update status
                            if (updateTimeBlock.numberofCase == 0 || updateTimeBlock.numberofCase <= clinic.maximumCase)
                            {
                                updateTimeBlock.status = "Free";
                            }

                            _TimeSlotRepo.Update(updateTimeBlock);

                            //Delete AppointmentTimeblock (1) ^
                            _AppTimeRepo.Delete(apptime);
                        }
                    }
                    // Then remove appointment (3)
                    _AppRepo.Delete(app);
                }
            }

            //Then Remove pet (4)
            IEnumerable <Pet> memPet = _PetRepo.GetByMemberID(memberid);

            if (memPet != null && memPet.Count() > 0)
            {
                foreach (var pet in memPet)
                {
                    _PetRepo.Delete(pet);
                }
            }

            Member member = _MemberRepo.GetByID(memberid);

            _MemberRepo.Delete(member);



            return(Json(new { Result = "Success" }));
        }
Exemplo n.º 3
0
        public TimeSlot Update(int id, TimeSlot item)
        {
            var data = _repo.GetById(id);

            data.BeginDatetime = item.BeginDatetime;
            data.EndDatetime   = item.EndDatetime;
            data.EngineerID    = item.EngineerID;
            data.Rate          = item.Rate;
            data.Status        = item.Status;

            return(_repo.Update(data));
        }
Exemplo n.º 4
0
 public long Execute()
 {
     return(timeSlotRepository.Update(TimeSlot));
 }