예제 #1
0
    static void Main(string[] args)
    {
        Guest g1 = new Guest(0, 0);

        g1.Create();
        LoggedUser l1 = new LoggedUser(5, 0991111111);

        l1.Create();
        Operator m1 = new Operator(901, 0992111111);

        m1.Create();
        CentalOperator a1 = new CentalOperator(1001, 0993111111);

        a1.Create();
        SuperUser su1 = new SuperUser(1, 1);

        su1.Create();
        Facade facade1 = new Facade(new Add_Sit(), new Calling());

        facade1.Operation1();
        facade1.Operation2();
        Calling cmntr1 = new Calling();
        Add_Sit artcl  = new Add_Sit();

        su1.SetCommand(new ArticleOnCommand(artcl));
        su1.DoSomething();
        su1.UndoSomething();
        su1.SetCommand(new CommentaryOnCommand(cmntr1));
        su1.DoSomething();
        su1.UndoSomething();

        Console.ReadLine();
    }
예제 #2
0
        public async Task <Guest> CreateAsync(long?ownerId = null)
        {
            var guest = Guest.Create(ownerId);

            guest.Id = await _guestRepository.InsertAndGetIdAsync(guest);

            return(guest);
        }
예제 #3
0
    static void Main(string[] args)
    {
        //Factory
        Guest g1 = new Guest(10, "guest10");

        g1.Create();
        LoggedUser l1 = new LoggedUser(11, "user007");

        l1.Create();
        Moderator m1 = new Moderator(12, "mod01");

        m1.Create();
        Admin a1 = new Admin(13, "adminushka2345");

        a1.Create();
        //Singleton
        SuperUser su1 = new SuperUser(14, "owner0987");

        su1.Create();
        //Facade
        Facade facade1 = new Facade(new Article(), new Commentary());

        facade1.Operation1();
        facade1.Operation2();
        //Command
        Commentary cmntr1 = new Commentary();
        Article    artcl  = new Article();

        su1.SetCommand(new ArticleOnCommand(artcl));
        su1.DoSomething();
        su1.UndoSomething();
        su1.SetCommand(new CommentaryOnCommand(cmntr1));
        su1.DoSomething();
        su1.UndoSomething();
        //Mediator
        ManagerMediator mediator = new ManagerMediator();
        SystemUser      customer = new CustomerSystemUser(mediator);
        SystemUser      moder    = new ModeratingSystemUser(mediator);

        mediator.Customer = customer;
        mediator.Moder    = moder;
        customer.Send("Please, add article on this topic...");
        moder.Send("Okay, here it is...");

        Console.ReadLine();
    }
    static void Main(string[] args)
    {
        Guest g1 = new Guest(0, 0);

        g1.Create();
        LoggedUser l1 = new LoggedUser(11, 0991111111);

        l1.Create();
        Operator m1 = new Operator(901, 0992111111);

        m1.Create();
        CentralOperator a1 = new CentralOperator(1001, 0993111111);

        a1.Create();

        SuperUser su1 = new SuperUser(1, 1);

        su1.Create();

        Facade facade1 = new Facade(new Add_Sit(), new Calling());

        facade1.Operation1();
        facade1.Operation2();

        Calling cmntr1 = new Calling();
        Add_Sit artcl  = new Add_Sit();

        su1.SetCommand(new ArticleOnCommand(artcl));
        su1.DoSomething();
        su1.UndoSomething();
        su1.SetCommand(new CommentaryOnCommand(cmntr1));
        su1.DoSomething();
        su1.UndoSomething();

        ManagerIntermediator intermediator = new ManagerIntermediator();
        SystemUser           customer      = new CustomerSystemUser(intermediator);
        SystemUser           moder         = new IntermoderatingSystemUser(intermediator);

        intermediator.Customer = customer;
        intermediator.Moder    = moder;
        customer.Send("I want to add a situation to the map");
        moder.Send("We checked it, everything is in order, it is already on the map");
        Console.ReadLine();
    }
예제 #5
0
    static void Main(string[] args)
    {
        Guest g1 = new Guest(10, 0);

        g1.Create();
        LoggedUser l1 = new LoggedUser(11, 0992111111);

        l1.Create();
        Operator m1 = new Operator(901, 0993111111);

        m1.Create();
        CentralOperator a1 = new CentralOperator(1001, 0994111111);

        a1.Create();
        Facade facade1 = new Facade(new Add_Sit(), new Calling());

        facade1.Operation1();
        facade1.Operation2();
        Console.ReadLine();
    }
예제 #6
0
        public void InviteGuest(string nameLast, string nameFirst, string email, string phone, string login, string password = "", int hours = 24)
        {
            if (this.CurrentPerson == null)
            {
                throw new CustomArgumentException("Person is undefined!");
            }

            if (String.IsNullOrEmpty(login))
            {
                throw new CustomArgumentException("Login can't be empty for new Guest!");
            }

            var now = CommonService.Now;

            var oldGuestsWithSameLogin = this.UnitOfWork.GuestRepository.GetAllByLogin(login);

            foreach (var oldGuest in oldGuestsWithSameLogin)
            {
                if (oldGuest.Expire > now)
                {
                    oldGuest.Disable();
                }
                this.UnitOfWork.GuestRepository.Update(oldGuest);
            }

            var pass = String.IsNullOrWhiteSpace(password) ? CommonService.GeneratePassword(8, false) : password;

            var guest = Guest.Create(this.CurrentPerson, new PersonName(nameFirst ?? "", nameLast ?? ""), email, phone, now.AddHours(hours), login, pass);

            this.UnitOfWork.GuestRepository.Add(guest);


            this.SaveChanges();

            DomainEvents.Raise(new GuestCreatedEvent(guest.Name, guest.Email, guest.Login, pass));
        }