public ActionResult Delete(Appointment appointment)
        {
            AppointmentContext appointmentContext = new AppointmentContext();

            appointmentContext.CancelAppointment(appointment);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(DateTime appointmentDateTime)
        {
            //The function checks if it possible to detrmine appointment at the required time
            if (!errorApointment(appointmentDateTime))
            {
                return(RedirectToAction("Index", "Appointment"));
            }

            int id = Convert.ToInt32(Session["CustomerId"]);

            Appointment appointment = new Appointment();

            TryUpdateModel <Appointment>(appointment);

            appointment.CustomerID          = id;
            appointment.AppointmentID       = 0;
            appointment.Status              = 1;
            appointment.StatusDateTime      = DateTime.Now;
            appointment.AppointmentDateTime = appointmentDateTime;

            AppointmentContext appointmentContext = new AppointmentContext();

            appointmentContext.AddAppointment(appointment);

            return(RedirectToAction("Index", "Appointment"));
        }
예제 #3
0
 public ActionResult Login_post(string userName, string password)
 {
     if (ModelState.IsValid)
     {
         using (AppointmentContext appointmentContext = new AppointmentContext())
         {
             List <Customer> customers = appointmentContext.Customer.ToList();
             var             obj       = customers.Where(a => a.UserName.Equals(userName) && a.Password.Equals(password.ComputeSha256Hash())).FirstOrDefault();
             if (obj != null)
             {
                 Session["CustomerID"] = obj.CustomerID.ToString();
                 Session["UserName"]   = obj.UserName.ToString();
                 Session["FirstName"]  = obj.FirstName.ToString();
                 Session["LastName"]   = obj.LastName.ToString();
                 return(RedirectToAction("Index", "Appointment"));
             }
             else if (userName == "" || password == "")
             {
                 return(View());
             }
             else
             {
                 TempData["invalidCustomer"] = "שם משתמש או סיסמה שגויים";
                 return(View());
             }
         }
     }
     TempData["invalidConnection"] = "פרטי התחברות שגויים";
     return(View());
 }
예제 #4
0
        public ActionResult Register_post()
        {
            if (ModelState.IsValid)
            {
                Customer customer = new Customer();
                TryUpdateModel <Customer>(customer);

                Session["CustomerId"] = customer.CustomerID;
                Session["UserName"]   = customer.UserName.ToString();
                Session["FirstName"]  = customer.FirstName.ToString();
                Session["LastName"]   = customer.LastName.ToString();

                AppointmentContext appointmentContext = new AppointmentContext();
                try
                {
                    appointmentContext.AddCustomer(customer);
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "הלקוח רשום במערכת";
                    return(View());
                }
                return(RedirectToAction("Index", "Appointment"));
            }
            return(View());
        }
        // GET: Appointment
        public ActionResult Index()
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            AppointmentContext appointmentContext = new AppointmentContext();
            List <Customer>    customers          = appointmentContext.Customer.ToList();
            List <Appointment> appointments       = appointmentContext.appointments.ToList();


            FullDetails        fullDetails;
            List <FullDetails> fullDetailsList = new List <FullDetails>();

            int id;

            foreach (Customer customer in customers)
            {
                id = customer.CustomerID;
                foreach (Appointment appointment in appointments.Where(c => c.CustomerID == id))
                {
                    fullDetails             = new FullDetails();
                    fullDetails.customer    = customer;
                    fullDetails.appointment = appointment;

                    fullDetailsList.Add(fullDetails);
                }
            }
            return(View(fullDetailsList));
        }
        public AppointmentController(AppointmentContext context, CenterContext cenContext, AppointmentResultContext resultContext)
        {
            CenterController _cenControl = new CenterController(cenContext);

            _context       = context;
            _cenContext    = cenContext;
            _resultContext = resultContext;

            if (_context.Appointments.Count() == 0)
            {
                _context.Appointments.Add(new Appointment {
                    ClientFullName = "ABC DEF", Date = "2019-09-13", CenterId = 1
                });
                _context.Appointments.Add(new Appointment {
                    ClientFullName = "GHI JKL", Date = "2019-09-14", CenterId = 2
                });

                _context.SaveChanges();
            }

            if (_resultContext.AppointmentResults.Count() == 0)
            {
                _resultContext.AppointmentResults.Add(new AppointmentResult {
                    ClientFullName = "ABC DEF", Date = "2019-09-13", Center = _cenContext.Centers.Single(c => c.Id == 1)
                });
                _resultContext.AppointmentResults.Add(new AppointmentResult {
                    ClientFullName = "GHI JKL", Date = "2019-09-14", Center = _cenContext.Centers.Single(c => c.Id == 2)
                });
                _resultContext.SaveChanges();
            }
        }
예제 #7
0
        public HomeController(ILogger <HomeController> logger, TimeSlotContext timeslotcontext, AppointmentContext appointmentcontext)
        {
            _logger = logger;

            //assigning the values to contexts
            _TimeSlotContext    = timeslotcontext;
            _AppointmentContext = appointmentcontext;
        }
예제 #8
0
        public AppointmentController(AppointmentContext context, IOptionsSnapshot <AppointmentSettings> settings, IAppointmentIntegrationEventService appointmentIntegrationEventService)
        {
            _appointmentContext = context ?? throw new ArgumentNullException(nameof(context));
            _appointmentIntegrationEventService = appointmentIntegrationEventService ?? throw new ArgumentNullException(nameof(appointmentIntegrationEventService));
            _settings = settings.Value;

            context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
        }
예제 #9
0
 public AppointmentReasonCodeChangedToAwaitingValidationIntegrationEventHandler(
     AppointmentContext appointmentContext,
     IAppointmentIntegrationEventService appointmentIntegrationEventService,
     ILogger <AppointmentReasonCodeChangedToAwaitingValidationIntegrationEventHandler> logger)
 {
     _appointmentContext = appointmentContext;
     _appointmentIntegrationEventService = appointmentIntegrationEventService;
     _logger = logger ?? throw new System.ArgumentNullException(nameof(logger));
 }
        //Pop-up
        public ActionResult Details(int customerID, int appointmentID)
        {
            AppointmentContext appointmentContext = new AppointmentContext();
            FullDetails        fullDetails        = new FullDetails();

            fullDetails.customer    = appointmentContext.Customer.Single(_customer => _customer.CustomerID == customerID);
            fullDetails.appointment = appointmentContext.appointments.Single(_appointment => _appointment.CustomerID == customerID && _appointment.AppointmentID == appointmentID);
            return(PartialView("Details", fullDetails));
        }
        public ActionResult Edit(int customerID, int appointmentID)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            AppointmentContext appointmentContext = new AppointmentContext();
            Appointment        appointment        = appointmentContext.appointments.Single(_appointment => _appointment.CustomerID == customerID && _appointment.AppointmentID == appointmentID);

            return(PartialView("Create", appointment));
        }
예제 #12
0
 public AppointmentIntegrationEventService(
     ILogger <AppointmentIntegrationEventService> logger,
     IEventBus eventBus,
     AppointmentContext appointmentContext,
     Func <DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory)
 {
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     _appointmentContext = appointmentContext ?? throw new ArgumentNullException(nameof(appointmentContext));
     _integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory));
     _eventBus        = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
     _eventLogService = _integrationEventLogServiceFactory(_appointmentContext.Database.GetDbConnection());
 }
예제 #13
0
        /// <summary>
        /// Legt die Datenbank an und befüllt sie mit Musterdaten. Die Datenbank ist
        /// nach Ausführen des Tests ServiceClassSuccessTest in
        /// SPG_Fachtheorie\SPG_Fachtheorie.Aufgabe2.Test\bin\Debug\net6.0\Appointment.db
        /// und kann mit SQLite Manager, DBeaver, ... betrachtet werden.
        /// </summary>
        private AppointmentContext GetAppointmentContext()
        {
            var options = new DbContextOptionsBuilder()
                          .UseSqlite("Data Source=Appointment.db")
                          .Options;

            var db = new AppointmentContext(options);

            db.Database.EnsureDeleted();
            db.Database.EnsureCreated();
            db.Seed();
            return(db);
        }
        //The function checks if it possible to detrmine appointment at the required time
        private Boolean errorApointment(DateTime appointmentDateTime)
        {
            //Case the user enter time that over
            if (appointmentDateTime < DateTime.Now)
            {
                TempData["timeOver"] = "מועד התור המבוקש חלף";
                return(false);
            }

            //Case the barbershop is close
            string day = appointmentDateTime.DayOfWeek.ToString();

            if (day == "Saturday")
            {
                TempData["barbershopClose"] = "המספרה סגורה במועד המבוקש";
                return(false);
            }
            else if (day == "Friday")
            {
                if (appointmentDateTime.Hour < 9 || appointmentDateTime.Hour > 14)
                {
                    TempData["barbershopClose"] = "המספרה סגורה במועד המבוקש";
                    return(false);
                }
            }
            else
            {
                if (appointmentDateTime.Hour < 9 || appointmentDateTime.Hour > 18)
                {
                    TempData["barbershopClose"] = "המספרה סגורה במועד המבוקש";
                    return(false);
                }
            }

            //Case the time of the appointment does not equal to xx:00 or xx:30
            if (appointmentDateTime.Minute != 30 && appointmentDateTime.Minute != 00)
            {
                TempData["errorTime"] = "לא ניתן לקבוע תור בשעה לא עגולה או חצי עגולה";
                return(false);
            }
            AppointmentContext appointmentContext = new AppointmentContext();

            //Case the appointment was caughted
            foreach (Appointment _appointment in appointmentContext.appointments.Where(a => a.AppointmentDateTime <appointmentDateTime.AddHours(1) && a.AppointmentDateTime> appointmentDateTime.AddHours(-1) && a.Status != 9))
            {
                TempData["notFreeApointnet"] = "מועד התור תפוס";
                return(false);
            }

            return(true);
        }
예제 #15
0
        public AppointmentController(AppointmentContext context)
        {
            appointmentContext = context;

            if (appointmentContext.Appointments.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                appointmentContext.Appointments.Add(new Appointment {
                    Title = "User1", IsPublic = true
                });
                appointmentContext.SaveChanges();
            }
        }
        public void Init()
        {
            var builder = new DbContextOptionsBuilder <AppointmentContext>();

            builder.UseInMemoryDatabase("AppointmentCalendar");
            DbContextOptions <AppointmentContext> options = builder.Options;

            _dbContext = new AppointmentContext(options);

            AddSampleDataToContext();

            _validator = new AppointmentValidator();

            _repository = new AppointmentRepository(_dbContext, _validator);
        }
        public ActionResult Edit_post(Appointment appointment)
        {
            if (!errorApointment(appointment.AppointmentDateTime))
            {
                return(RedirectToAction("Index", "Appointment"));
            }

            if (ModelState.IsValid)
            {
                AppointmentContext appointmentContext = new AppointmentContext();
                appointmentContext.UpdateAppointment(appointment);
                return(RedirectToAction("Index"));
            }
            return(View(appointment));
        }
예제 #18
0
        //public class SubscribeRequest
        //{
        //    public int userId { get; set; }
        //    public int eventId{ get; set; }
        //}

        public UserController(UserContext context, AppointmentContext appointmentContext)
        {
            _context = context;
            this.appointmentContext = appointmentContext;

            if (_context.Users.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                User a = new User
                {
                    Username = "******"
                };
                _context.Users.Add(a);

                _context.SaveChanges();
            }
        }
예제 #19
0
        public static async Task DispatchDomainEventsAsync(this IMediator mediator, AppointmentContext ctx)
        {
            var domainEntities = ctx.ChangeTracker
                                 .Entries <Entity>()
                                 .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any());

            var domainEvents = domainEntities
                               .SelectMany(x => x.Entity.DomainEvents)
                               .ToList();

            domainEntities.ToList()
            .ForEach(entity => entity.Entity.ClearDomainEvents());

            var tasks = domainEvents
                        .Select(async(domainEvent) => {
                await mediator.Publish(domainEvent);
            });

            await Task.WhenAll(tasks);
        }
예제 #20
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(new ValidationResult("Time field is required"));
            }

            // getting AppointmentContext via ValidationContext
            AppointmentContext dbcontext = (AppointmentContext)validationContext.GetService(typeof(AppointmentContext));
            var times = from a in dbcontext.Appointment select a.Time;

            bool containsValue = times.Any(a => a == (int)value);

            if (containsValue)
            {
                return(new ValidationResult("Unfortunately, this time is not available"));
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
 public BeamerService(AppointmentContext context)
 {
     _context = context;
 }
예제 #22
0
 public HomeController(ILogger <HomeController> logger, AppointmentContext con)
 {
     _logger = logger;
     context = con;
 }
 public AppointmentRepository(AppointmentContext dbContext, IValidator <Appointment> validator) : base(dbContext, validator)
 {
 }
예제 #24
0
 public UnitOfWork(string connectionString)
 {
     this.context = new AppointmentContext(connectionString);
     _doctors     = new DoctorRepository(context);
     _appointment = new AppointmentRepository(context);
 }
예제 #25
0
 public AppointmentsController(AppointmentContext context)
 {
     _context = context;
 }
예제 #26
0
 public IndexModel(AppointmentContext db, AuthService authService)
 {
     _db          = db;
     _authService = authService;
 }
예제 #27
0
 public PostRepository(AppointmentContext context) : base(context)
 {
 }
예제 #28
0
 public Repository(AppointmentContext dbContext,
                   IValidator <TEntity> validator)
 {
     _dbContext = dbContext;
     _validator = validator;
 }
예제 #29
0
 public SurveyService(AppointmentContext context)
 {
     _context = context;
 }
 public RessourceService(AppointmentContext context)
 {
     _context = context;
 }