public void Edit(Renovation entity)
 {
     if (AuthorizedUsers["Edit"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         RenovationController.Edit(entity);
     }
 }
Esempio n. 2
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var selectedTemplate = AppointmentTemplate;

            CalendarEntry calendarEntry;

            if (item is CalendarEntryBindableViewModel calendarEntryBindableViewModel)
            {
                calendarEntry = calendarEntryBindableViewModel?.CalendarEntry;
            }
            else
            {
                calendarEntry = (CalendarEntry)item;
            }

            selectedTemplate = calendarEntry switch
            {
                Surgery _ => SurgeryTemplate,
                Appointment _ => AppointmentTemplate,
                Renovation _ => RenovationTemplate,
                        _ => selectedTemplate
            };
            return(selectedTemplate);
        }
    }
 public void Delete(Renovation entity)
 {
     if (AuthorizedUsers["Delete"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         RenovationController.Delete(entity);
     }
 }
 public Renovation Save(Renovation entity)
 {
     if (AuthorizedUsers["Save"].SingleOrDefault(any => any.Equals(Role)) != null)
     {
         return(RenovationController.Save(entity));
     }
     return(null);
 }
 private bool validateDates(Renovation entity)
 {
     if (DateTime.Compare(entity.Period.StartDate, entity.Period.EndDate) >= 0)
     {
         return(false);
     }
     return(true);
 }
 public Renovation EditRenovation(Renovation renovation)
 {
     renovationRepository.Update(renovation);
     if (renovation.MoveEquipment)
     {
         MoveAllToStorage(renovation);
     }
     return(renovation);
 }
 public Renovation Add(Renovation renovation)
 {
     if (Get(renovation.Id) == null)
     {
         List <Renovation> renovations = GetAll();
         renovations.Add(renovation);
         WriteAll(renovations);
         return(renovation);
     }
     return(null);
 }
 public Renovation Save(Renovation entity)
 {
     if (validateDates(entity))
     {
         return(_repository.Save(entity));
     }
     else
     {
         return(null);
     }
 }
        private bool CheckIfHasNewAppointments(Renovation renovation)
        {
            var allAppointments = appointmentRepository.GetScheduledFromToday();

            if (allAppointments.Any(ent => ent.Value.Room.RoomID == renovation.Room.RoomID) &&
                allAppointments.Any(ent2 => ent2.Value.StartTime.Date.CompareTo(renovation.StartDate.Date) >= 0 &&
                                    allAppointments.Any(ent1 => ent1.Value.StartTime.Date.CompareTo(renovation.EndDate.Date) <= 0)))
            {
                throw new RoomHasAppointments(string.Format(HAS_APPOINTMENTS, renovation.Room.RoomID));
            }
            return(true);
        }
        public void MoveAllToStorage(Renovation renovation)
        {
            Room roomToUpdate = roomService.GetRoom(renovation.Room.RoomID);
            var  storages     = roomService.GetAllRoomsFromOneType(RoomType.storage).ToList();

            foreach (HospitalEquipment equipment in hospitalEquipmentService.GetEquipmentByRoomNumber(roomToUpdate.RoomID))
            {
                //     equipment.Room = storages[0];
                //   equipment.RoomNumberIn = storages[0].RoomNumber;
                hospitalEquipmentService.UpdateEquipment(equipment);
            }
        }
 public Renovation CreateNewRenovation(Renovation renovation)
 {
     if (CheckIfHasNewAppointments(renovation))
     {
         renovationRepository.Create(renovation);
         notificationService.RenovationNotification();
         if (renovation.MoveEquipment)
         {
             MoveAllToStorage(renovation);
         }
         return(renovation);
     }
     return(null);
 }
        public Renovation Remove(int id)
        {
            List <Renovation> renovations = GetAll();

            Renovation renovationToRemove = renovations.SingleOrDefault(r => r.Id == id);

            if (renovationToRemove != null)
            {
                renovations.Remove(renovationToRemove);
                WriteAll(renovations);
            }

            return(renovationToRemove);
        }
        public Renovation Update(Renovation renovation)
        {
            List <Renovation> renovations = GetAll();

            for (int i = 0; i < renovations.Count; i++)
            {
                if (renovations[i].Id == renovation.Id)
                {
                    renovations[i] = renovation;
                    break;
                }
            }

            WriteAll(renovations);

            return(renovation);
        }
Esempio n. 14
0
        public void RealiseRenovation(Renovation renovation)
        {
            Room room = _roomRepository.GetById(renovation.Room.Id);

            if (renovation.Type.Equals("Rusenje"))
            {
                _roomRepository.Remove(room);
            }
            else if (renovation.Type.Equals("Pregradjivanje"))
            {
                room.Type = renovation.NewType;
                _roomRepository.Save(room);
            }
            else if (renovation.Type.Equals("Promena funkcije"))
            {
                room.Type = renovation.NewType;
                _roomRepository.Update(room);
            }
            Remove(renovation);
        }
Esempio n. 15
0
        internal Renovation GetFutureRenovation(int id)
        {
            Room room = Get(id);

            if (room == null || room.Renovation == null)
            {
                return(null);
            }

            foreach (var renovationId in room.Renovation)
            {
                Renovation renovation = _renovationRepository.Get(renovationId);
                if (renovation != null)
                {
                    if (renovation.Date > DateTime.Now.Date)
                    {
                        return(renovation);
                    }
                }
            }
            return(null);
        }
 public bool DeleteRenovation(Renovation renovation) => renovationService.DeleteRenovation(renovation);
 public Renovation EditRenovation(Renovation renovation) => renovationService.EditRenovation(renovation);
 public void Delete(Renovation entity)
 {
     _renovationService.Delete(entity);
 }
Esempio n. 19
0
 public Renovation AddRenovation(Renovation renovation)
 {
     return(_roomService.AddRenovation(renovation));
 }
Esempio n. 20
0
 public void DeleteRenovation(Renovation renovation)
 {
     renovationRepository.Delete(renovation.SerialNumber);
 }
 public void DeleteRenovation(Renovation renovation)
 {
     renovationService.DeleteRenovation(renovation);
 }
 public Renovation Save(Renovation entity)
 {
     return(_renovationService.Save(entity));
 }
 public void Edit(Renovation entity)
 {
     _renovationService.Edit(entity);
 }
 public void MoveAllToStorage(Renovation renovation) => renovationService.MoveAllToStorage(renovation);
 public bool DeleteRenovation(Renovation renovation) => renovationRepository.Delete(renovation);
 public Renovation CreateNewRenovation(Renovation renovation) => renovationService.CreateNewRenovation(renovation);
 public void EditRenovation(Renovation renovation)
 {
     renovationService.EditRenovation(renovation);
 }
Esempio n. 28
0
 public void NewRenovation(Renovation renovation)
 {
     renovationRepository.Save(renovation);
 }
 public void NewRenovation(Renovation renovation)
 {
     renovationService.NewRenovation(renovation);
 }
Esempio n. 30
0
 internal Renovation AddRenovation(Renovation renovation)
 => _renovationRepository.Add(renovation);