public static void Main()
        {
            Approver teamLead = new TeamLead();
            Approver vicePresident = new VicePresident();
            Approver president = new President();

            teamLead.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            Purchase purchase = new Purchase(2019, 90000.00);
            teamLead.ProcessRequest(purchase);
        }
Пример #2
0
        public static void Main()
        {
            Approver teamLead = new TeamLead();
            Approver vp = new VicePresident();
            Approver ceo = new President();

            teamLead.SetSuccessor(vp);
            vp.SetSuccessor(ceo);

            var purchase = new Purchase(2034, 350.00);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(2035, 32590.10);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(2036, 122100.00);
            teamLead.ProcessRequest(purchase);
        }
        internal static void Main()
        {
            Approver teamLead = new TeamLead();
            Approver vicePresident = new VicePresident();
            Approver president = new President();

            teamLead.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            var purchase = new Purchase(2034, 350.00);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(2035, 32590.10);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(2036, 122100.00);
            teamLead.ProcessRequest(purchase);
        }
Пример #4
0
        private static void Main()
        {
            var larry = new Director();
            var sam = new VicePresident();
            var tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            var purchase = new Purchase(1231, 350.0, "Assets");
            larry.ProcessRequest(purchase);

            purchase = new Purchase(321, 12313.123, "Project X");
            larry.ProcessRequest(purchase);

            purchase = new Purchase(123123, 123123123.123, "Project Y");
            larry.ProcessRequest(purchase);
        }
Пример #5
0
        static void Main()
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            // Generate and process purchase requests
            Purchase p = new Purchase(2034, 350.00, "Assets");

            larry.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);
        }
            static void Main(string[] args)
            {
                PurchaseRequest requestTelphone  = new PurchaseRequest(4000.0, "Telphone");
                PurchaseRequest requestSoftware  = new PurchaseRequest(10000.0, "Visual Studio");
                PurchaseRequest requestComputers = new PurchaseRequest(40000.0, "Computers");

                Approver manager = new Manager("LearningHard");
                Approver Vp      = new VicePresident("Tony");
                Approver Pre     = new President("BossTom");

                // 设置责任链
                manager.NextApprover = Vp;
                Vp.NextApprover      = Pre;

                // 处理请求
                manager.ProcessRequest(requestTelphone);
                manager.ProcessRequest(requestSoftware);
                manager.ProcessRequest(requestComputers);
                Console.ReadLine();
            }
Пример #7
0
        public void MapTo_President_To_PresidentDto()
        {
            var entity = new President
            {
                Id      = "1234",
                Name    = "George",
                Address = new Address("Rua de Teste", "123", "APT 12", new ZipCode("12345678"))
            };

            var mappDto = entity.MapTo <PresidentDto>();

            Assert.NotNull(mappDto);
            Assert.Equal(entity.Id, mappDto.Id);
            Assert.Equal(entity.Name, mappDto.Name);
            Assert.NotNull(mappDto.Address);
            Assert.Equal(entity.Address.Complement, mappDto.Address.Complement);
            Assert.Equal(entity.Address.Number, mappDto.Address.Number);
            Assert.Equal(entity.Address.Street, mappDto.Address.Street);
            Assert.Equal(entity.Address.ZipCode.Number, mappDto.Address.ZipCode.Number);
        }
Пример #8
0
        public List <President> GetPresidents()
        {
            string file = "BackingStore.csv";
            string path = System.IO.Path.GetFullPath(file);

            path = path.Replace(file, "bin\\Debug\\netcoreapp2.0\\" + file);
            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                using (StreamReader streamReader = new StreamReader(fileStream))
                {
                    List <President> presidents = new List <President>()
                    {
                    };
                    string concatenation = streamReader.ReadToEnd();
                    if (concatenation.Contains("\n") && !concatenation.Contains("\r\n"))
                    {
                        concatenation = concatenation.Replace("\n", "\r\n");
                    }
                    foreach (string scrapping in concatenation.Split("\r\n"))
                    {
                        President president  = new President();
                        string[]  scrappings = scrapping.Split(",");
                        if (scrappings.Length > 2)
                        {
                            president.HasNonconsecutiveTerms = Convert.ToBoolean(scrappings[2]);
                        }
                        if (scrappings.Length > 1 && !String.IsNullOrWhiteSpace(scrappings[1]))
                        {
                            president.Party = scrappings[1].Trim();
                        }
                        president.Name = scrappings[0].Trim();
                        presidents.Add(president);
                    }
                    if (presidents[presidents.Count - 1].Name == null || presidents[presidents.Count - 1].Name == "")
                    {
                        presidents.RemoveAt(presidents.Count - 1);
                    }
                    return(presidents);
                }
            }
        }
Пример #9
0
        public ActionResult EditImg(int id, HttpPostedFileBase file)
        {
            President c = new President();

            c = Ps.Get(t => t.Id == id);

            var fileName = "";

            if (file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);

                var path = Path.Combine(Server.MapPath("~/Content/Upload/"), file.FileName);
                file.SaveAs(path);
            }

            c.Logo = file.FileName;
            Ps.Update(c);
            Ps.Commit();
            return(RedirectToAction("Details", new { id = c.Id }));
        }
Пример #10
0
        static void Main(string[] args)
        {
            Approver larry = new MiddleManager();
            Approver bob = new VicePresident();
            Approver joe = new President();
            Approver end = new EndOfChain();

            larry.SetSuccessor(bob);
            bob.SetSuccessor(joe);
            joe.SetSuccessor(end);

            Purchase purchase1 = new Purchase { Amount = 100, Number = 1, Purpose = "R&D (Rest&Darts)" };
            Purchase purchase2 = new Purchase { Amount = 5000, Number = 2, Purpose = "Moose hunting" };
            Purchase purchase3 = new Purchase { Amount = 1000000, Number = 3, Purpose = "Bribery" };

            Console.WriteLine("Response for {0}: {1}", purchase1.ToString(), larry.ProcessRequest(purchase1));
            Console.WriteLine("Response for {0}: {1}", purchase2.ToString(), larry.ProcessRequest(purchase2));
            Console.WriteLine("Response for {0}: {1}", purchase3.ToString(), larry.ProcessRequest(purchase3));

            Console.ReadLine();
        }
Пример #11
0
        static void Main(string[] args)
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            Purchase p = new Purchase(2034, 350.00, "Assets");

            larry.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);

            Console.ReadKey();
        }
        public void Run(IUnityContainer Container)
        {
            // Setup Chain of Responsibility
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            // Generate and process purchase requests
            Purchase p = new Purchase(2034, 350.00, "Assets");

            larry.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);
        }
Пример #13
0
        public static List <President> CSVMapping(List <DAL.Models.President> president)
        {
            List <President> rec2 = new List <President>();

            foreach (var r in president)
            {
                rec2.Add(new President());
                President r2 = rec2.Last();
                r2.PresidentName = r.PresidentName;
                DateTime bd = new DateTime();
                DateTime dd = new DateTime();
                if (DateTime.TryParse(r.BirthDate, out bd))
                {
                    r2.BirthDate = bd;
                }
                if (DateTime.TryParse(r.DeathDate, out dd))
                {
                    r2.DeathDate = dd;
                }
            }
            return(rec2);
        }
Пример #14
0
	public void startGiveItemDialog(President _pObj){
		pObj = _pObj;

		DialogSystem.character[] nameString ={
			DialogSystem.character.PRINCIPAL,
			DialogSystem.character.PLAYER,
			DialogSystem.character.PRINCIPAL,
			DialogSystem.character.PLAYER,
			DialogSystem.character.PRINCIPAL,
			DialogSystem.character.PLAYER
			};
		string[] dialogString = new string[]{
			"Hey, that guy over there!!",
			"......?",
			"Don't you recongise me?",
			"(Familiar face but can't remember who...)",
			"Do you work hard on your studies? \nGive you an APPLE and keep it on!",
			"Thank you...\n(what a strange man...)"
		};
		//dsObj.startDialog(nameString, dialogString);
		conversation (nameString, dialogString, 1);
	}
Пример #15
0
        static void Main(string[] args)
        {
            Approver temaLead      = new TeamLead();
            Approver vicePresident = new VicePresident();
            Approver president     = new President();

            temaLead.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            var purchase = new Purchase(350, 1);

            temaLead.ProcessRequest(purchase);

            purchase = new Purchase(24000, 2);
            temaLead.ProcessRequest(purchase);

            purchase = new Purchase(32590, 3);
            temaLead.ProcessRequest(purchase);

            purchase = new Purchase(100001, 4);
            temaLead.ProcessRequest(purchase);
        }
Пример #16
0
 // GET: President/Details/5
 public ActionResult Details(int id)
 {
     if (RoleUser() == "User")
     {
         President P = new President();
         P = Ps.Get(t => t.Id == id);
         PresidentModel Pm = new PresidentModel();
         Pm.Id            = P.Id;
         Pm.PresidentName = P.PresidentName;
         Pm.Email         = P.Email;
         Pm.PhoneNumber   = P.PhoneNumber;
         Pm.StreetName    = P.StreetName;
         Pm.City          = P.City;
         Pm.Logo          = P.Logo;
         Pm.Photo         = P.Photo;
         return(View(Pm));
     }
     else
     {
         return(HttpNotFound());
     }
 }
Пример #17
0
        static void Main(string[] args)
        {
            // Setup Chain of Responsibility

            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();
            Approver July  = new Chairperson();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(July);
            July.SetSuccessor(tammy);

            // Generate and process purchase requests

            Purchase purchase1 = new Purchase(2034, 5000.00, "Assets");

            larry.ProcessRequest(purchase1);

            Purchase purchase2 = new Purchase(2035, 20000.00, "Keyboard");

            larry.ProcessRequest(purchase2);

            Purchase purchase3 = new Purchase(2036, 30000.00, "Mouse");

            larry.ProcessRequest(purchase3);

            Purchase purchase4 = new Purchase(2037, 90000.00, "CPU");

            larry.ProcessRequest(purchase4);

            Purchase purchase5 = new Purchase(2038, 600000.00, "GPU");

            larry.ProcessRequest(purchase5);

            // Wait for user

            Console.ReadKey();
        }
Пример #18
0
        public static void TestApprovals()
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            Purchase p        = new Purchase(2034, 350.00, "Assets");
            var      p1result = larry.ProcessRequest(p, true);

            Assert.AreEqual(p1result, larry);
            p = new Purchase(2035, 32590.10, "Project X");
            var p2result = larry.ProcessRequest(p, true);

            Assert.AreEqual(p2result, tammy);
            p = new Purchase(2036, 122100.00, "Project Y");
            var p3result = larry.ProcessRequest(p, true);

            Assert.AreEqual(p3result, null);
        }
Пример #19
0
        public static void Main()
        {
            Approver teamLead      = new TeamLead();
            Approver vicePresident = new VicePresident();
            Approver president     = new President();

            teamLead.SetNext(vicePresident);
            vicePresident.SetNext(president);

            var purchase = new Purchase(350, 1);

            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(24000, 2);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(32590, 3);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(100001, 4);
            teamLead.ProcessRequest(purchase);
        }
Пример #20
0
        static void ChainOfResponsibilityTester()
        {
            #region sample 1
            // Setup Chain of Responsibility
            Handler h1 = new ConcreteHandler1();
            Handler h2 = new ConcreteHandler2();
            Handler h3 = new ConcreteHandler3();
            h1.SetSuccessor(h2);
            h2.SetSuccessor(h3);

            // Generate and process request
            int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 };

            foreach (int request in requests)
            {
                h1.HandleRequest(request);
            }
            #endregion

            #region sample 2
            // Setup Chain of Responsibility
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            // Generate and process purchase requests
            Purchase p = new Purchase(2034, 350.00, "Assets");
            larry.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);
            #endregion
        }
        public List <President> GetAll()
        {
            try
            {
                List <President> list = new List <President>();

                foreach (var value in context.result.Values)
                {
                    //Creates the president object
                    var president = new President()
                    {
                        Name       = value[0].ToString(),
                        Birthday   = Convert.ToDateTime(value[1]),
                        Birthplace = value[2].ToString(),
                    };

                    //Checks if deathday and deathplace is null
                    if (value.Count > 3)
                    {
                        president.Deathday   = Convert.ToDateTime(value[3]);
                        president.Deathplace = value[4].ToString();
                    }
                    else
                    {
                        president.Deathday   = (DateTime?)null;
                        president.Deathplace = "";
                    }

                    list.Add(president);
                }

                return(list);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #22
0
        public async Task <IActionResult> Create(President president, IFormFile Photo)
        {
            if (Photo != null && Photo.Length > 0)
            {
                Stream stream = Photo.OpenReadStream();
                using (var memoryStream = new MemoryStream())
                {
                    stream.CopyTo(memoryStream);
                    president.Photo = memoryStream.ToArray();
                }
            }

            int CountriCode = Int32.Parse(president.PresCountry);



            var newContri = await _context.CountryTB.SingleOrDefaultAsync(m => m.CountryId == CountriCode);

            var newCapi = await _context.CapitalCityTB.SingleOrDefaultAsync(m => m.CapCountry == newContri.CountryName);



            president.PresCountry   = newContri.CountryName;
            president.PresContinent = newContri.CounContinent;
            president.PresCapital   = newCapi.CapitalCityName;


            president.CreatedDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(president);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(president));
        }
Пример #23
0
 public ActionResult ProfilePresident()
 {
     if (RoleUser() == "President")
     {
         President P  = new President();
         var       id = Int32.Parse(User.Identity.GetUserId());
         P = Ps.Get(t => t.Id == id);
         PresidentModel Pm = new PresidentModel();
         Pm.Id            = P.Id;
         Pm.PresidentName = P.PresidentName;
         Pm.Email         = P.Email;
         Pm.PhoneNumber   = P.PhoneNumber;
         Pm.StreetName    = P.StreetName;
         Pm.City          = P.City;
         Pm.Photo         = P.Photo;
         Pm.Logo          = P.Logo;
         return(View(Pm));
     }
     else
     {
         return(HttpNotFound());
     }
 }
Пример #24
0
        private List <President> PopulatePresidentsFromXml(string xml)
        {
            var returnValue = new List <President>();

            var root = XElement.Parse(xml);

            var presidents = root.ElementsByLocalName("president");

            President groverCleveland = null;

            foreach (var fromElement in presidents)
            {
                var currentPresident = GetPresidentFromXml(fromElement);

                if (currentPresident.LastName == "Cleveland")
                {
                    // grover cleveland had two non-consecutive terms
                    // only create one record for grover
                    // with two terms
                    if (groverCleveland == null)
                    {
                        groverCleveland = currentPresident;
                        returnValue.Add(currentPresident);
                    }
                    else
                    {
                        groverCleveland.Terms.Add(currentPresident.Terms[0]);
                    }
                }
                else
                {
                    returnValue.Add(currentPresident);
                }
            }

            return(returnValue);
        }
Пример #25
0
        static void Main(string[] args)
        {
            // Setup Chain of Responsibility

            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new Secretary();
            Approver raul  = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);
            tammy.SetSuccessor(raul);

            // Generate and process purchase requests

            Purchase p = new Purchase(2034, 350.00, "Assets");

            larry.ProcessRequest(p);

            p = new Purchase(2035, 22999.99, "Project X");
            larry.ProcessRequest(p);


            p = new Purchase(2036, 32590.10, "New car");
            larry.ProcessRequest(p);

            p = new Purchase(2037, 91000.00, "Project Almanaq");
            larry.ProcessRequest(p);


            p = new Purchase(5451, 85000250.50, "New house for Raúl");
            larry.ProcessRequest(p);

            // Wait for user

            Console.ReadKey();
        }
Пример #26
0
        public ActionResult Edit(President president)
        {
            if (ModelState.IsValid)
            {
                bool isCreateNew = false;

                if (president.Id == ID_FOR_CREATE_NEW_PRESIDENT)
                {
                    isCreateNew = true;
                }
                else
                {
                    President toValue =
                        _Service.GetPresidentById(president.Id);

                    if (toValue == null)
                    {
                        return(new HttpStatusCodeResult(
                                   HttpStatusCode.BadRequest,
                                   String.Format("Unknown president id '{0}'.", president.Id)));
                    }
                }

                _Service.Save(president);

                if (isCreateNew == true)
                {
                    RedirectToAction("Edit", new { id = president.Id });
                }
                else
                {
                    return(RedirectToAction("Edit"));
                }
            }

            return(View(president));
        }
Пример #27
0
        static void Main()
        {
            // Setup Chain of Responsibility
            Approver ronny = new Director();
            Approver bobby = new VicePresident();
            Approver ricky = new President();

            ronny.SetSuccessor(bobby);
            bobby.SetSuccessor(ricky);

            // Generate and process purchase requests
            Purchase p = new Purchase(8884, 350.00, "Assets");

            ronny.ProcessRequest(p);

            p = new Purchase(5675, 33390.10, "Project Poison");
            ronny.ProcessRequest(p);

            p = new Purchase(5676, 144400.00, "Project BBD");
            ronny.ProcessRequest(p);

            // Wait for user
            Console.ReadKey();
        }
Пример #28
0
        public void Adapt(President fromValue, Person toValue)
        {
            if (fromValue == null)
            {
                throw new ArgumentNullException("fromValue", "fromValue is null.");
            }
            if (toValue == null)
            {
                throw new ArgumentNullException("toValue", "toValue is null.");
            }

            toValue.Id        = fromValue.Id;
            toValue.FirstName = fromValue.FirstName;
            toValue.LastName  = fromValue.LastName;

            if (fromValue.Id == 0)
            {
                toValue.Facts.Clear();
            }

            AdaptFacts(fromValue, toValue);

            AdaptTerms(fromValue, toValue);
        }
        public static void SavePresident(string name, int age, int id)
        {
            President president;

            var countryModelsList = new List <CountryModel>();
            var sessionFactory    = SessionFactory.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    president = new President
                    {
                        Id   = id,
                        Name = name,
                        Age  = age,
                    };


                    session.SaveOrUpdate(president);
                    transaction.Commit();
                }
            }
        }
        public void ReadEntries()
        {
            bool skipped = false;
            var  range   = $"{sheet}!A:E";

            SpreadsheetsResource.ValuesResource.GetRequest request =
                _service.Spreadsheets.Values.Get(SpreadsheetId, range);

            var response = request.Execute();
            IList <IList <object> > values = response.Values;

            DataList = new List <President>();

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    // Save columns A to F, which correspond to indices 0 and 4.
                    if (header && !skipped)
                    {
                        skipped = true;
                    }
                    else
                    {
                        President p = new President();
                        p.Name       = row[0].ToString();
                        p.Birthday   = row[1].ToString();
                        p.Birthplace = row[2].ToString();
                        p.DeathDay   = row.Count > 3 ? row[3].ToString() : null;
                        p.DeathPlace = row.Count > 4 ? row[4].ToString() : null;

                        DataList.Add(p);
                    }
                }
            }
        }
Пример #31
0
 public ActionResult Register(CandidateRegistrationViewModel candidate)
 {
     if (!ModelState.IsValid)
     {
         var register = new CandidateRegistrationViewModel();
         ViewBag.QualificationId = ListQualification();
         ViewBag.PostingId       = ListPost();
         return(View(register));
     }
     if (candidate.PostingId == 1)
     {
         var president = new President
         {
             CandidateName       = candidate.CandidateName,
             CurrentOccupation   = candidate.CurrentOccupation,
             PreviousRWAMember   = candidate.PreviousRWAMember,
             PartOfGovtPoliceNGO = candidate.PartOfGovtPoliceNGO,
             CriminalRecord      = candidate.CriminalRecord,
             Age             = candidate.Age,
             Gender          = candidate.Gender,
             QualificationId = candidate.QualificationId
         };
         dbContext.Presidents.Add(president);
         dbContext.SaveChanges();
     }
     if (candidate.PostingId == 2)
     {
         var vicepresident = new VicePresident
         {
             CandidateName       = candidate.CandidateName,
             CurrentOccupation   = candidate.CurrentOccupation,
             PreviousRWAMember   = candidate.PreviousRWAMember,
             PartOfGovtPoliceNGO = candidate.PartOfGovtPoliceNGO,
             CriminalRecord      = candidate.CriminalRecord,
             Age             = candidate.Age,
             Gender          = candidate.Gender,
             QualificationId = candidate.QualificationId
         };
         dbContext.VicePresident.Add(vicepresident);
         dbContext.SaveChanges();
     }
     if (candidate.PostingId == 3)
     {
         var secretary = new Secretary
         {
             CandidateName       = candidate.CandidateName,
             CurrentOccupation   = candidate.CurrentOccupation,
             PreviousRWAMember   = candidate.PreviousRWAMember,
             PartOfGovtPoliceNGO = candidate.PartOfGovtPoliceNGO,
             CriminalRecord      = candidate.CriminalRecord,
             Age             = candidate.Age,
             Gender          = candidate.Gender,
             QualificationId = candidate.QualificationId,
         };
         dbContext.Secretary.Add(secretary);
         dbContext.SaveChanges();
     }
     if (candidate.PostingId == 4)
     {
         var treasurer = new Treasurer
         {
             CandidateName       = candidate.CandidateName,
             CurrentOccupation   = candidate.CurrentOccupation,
             PreviousRWAMember   = candidate.PreviousRWAMember,
             PartOfGovtPoliceNGO = candidate.PartOfGovtPoliceNGO,
             CriminalRecord      = candidate.CriminalRecord,
             Age             = candidate.Age,
             Gender          = candidate.Gender,
             QualificationId = candidate.QualificationId,
         };
         dbContext.Treasurer.Add(treasurer);
         dbContext.SaveChanges();
     }
     if (candidate.PostingId == 5)
     {
         var members = new Members
         {
             CandidateName       = candidate.CandidateName,
             CurrentOccupation   = candidate.CurrentOccupation,
             PreviousRWAMember   = candidate.PreviousRWAMember,
             PartOfGovtPoliceNGO = candidate.PartOfGovtPoliceNGO,
             CriminalRecord      = candidate.CriminalRecord,
             Age             = candidate.Age,
             Gender          = candidate.Gender,
             QualificationId = candidate.QualificationId,
         };
         dbContext.Members.Add(members);
         dbContext.SaveChanges();
     }
     return(RedirectToAction("Index", "Home"));
 }
    // Entry point into console application.
    static void Main()
    {
        // Setup Chain of Responsibility (bottom-up)
        Approver larry = new Director();
        Approver sam = new VicePresident();
        Approver tammy = new President();

        larry.SetSuccessor(sam);
        sam.SetSuccessor(tammy);

        // Generate and process purchase requests
        Purchase p = new Purchase(2034, 350.00, "Assets");
        larry.ProcessRequest(p);

        p = new Purchase(2035, 32590.10, "Project X");
        larry.ProcessRequest(p);

        p = new Purchase(2036, 92100.00, "Project Y");
        larry.ProcessRequest(p);

        p = new Purchase(2037, 122100.00, "Project Y");
        larry.ProcessRequest(p);

        // Wait for user
        Console.ReadKey();
    }
Пример #33
0
 public bool IsValid(President validateThis)
 {
     return(IsValidReturnValue);
 }
Пример #34
0
        public President GetPresident(int id)
        {
            President president = _presidentsRepository.FindById(id);

            return(president);
        }
Пример #35
0
  public static void Main( string[] args )
  {
    // Setup Chain of Responsibility
    Director Larry = new Director( "Larry" );
    VicePresident Sam = new VicePresident( "Sam" );
    President Tammy = new President( "Tammy" );
    Larry.SetSuccessor( Sam );
    Sam.SetSuccessor( Tammy );

    // Generate and process different requests
    PurchaseRequest rs = new PurchaseRequest( 
                          2034, 350.00, "Supplies" );
    Larry.ProcessRequest( rs );

    PurchaseRequest rx = new PurchaseRequest( 
                          2035, 32590.10, "Project X" );
    Larry.ProcessRequest( rx );

    PurchaseRequest ry = new PurchaseRequest( 
                          2036, 122100.00, "Project Y" );
    Larry.ProcessRequest( ry );

  }
Пример #36
0
        public async Task <ActionResult> Register(RegisterViewModel model, HttpPostedFileBase Image)
        {
            if (model.Role == "Participant")
            {
                if (ModelState.IsValid)
                {
                    var fileName = Path.GetFileName(Image.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/Upload/"), fileName);
                    Image.SaveAs(path);
                    var user = new Participant {
                        UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Password = model.Password, PhoneNumber = model.PhoneNumber, PhoneNumberConfirmed = true, Gender = model.Gender, BirthDate = model.BirthDate, City = model.City, HomeAddress = model.HomeAddress, Image = fileName
                    };
                    var result = await Manager.CreateAsync(user, model.Password);



                    // var path = Path.Combine(Server.MapPath("~/Content/Upload/"), Image.FileName);

                    // Image.SaveAs(path);
                    //// model.Image = Image.FileName;
                    if (result.Succeeded)
                    {
                        //  await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        // Pour plus d'informations sur l'activation de la confirmation du compte et la réinitialisation du mot de passe, consultez http://go.microsoft.com/fwlink/?LinkID=320771
                        // Envoyer un message électronique avec ce lien
                        string code = await Manager.GenerateEmailConfirmationTokenAsync(user.Id);

                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        await Manager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                        return(RedirectToAction("Login", "Account"));
                    }
                    AddErrors(result);
                }

                // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
                return(View(model));
            }
            else if (model.Role == "President")
            {
                if (ModelState.IsValid)
                {
                    var fileName = Path.GetFileName(Image.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Content/Upload/"), fileName);
                    Image.SaveAs(path);

                    var user = new President {
                        UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Password = model.Password, PhoneNumber = model.PhoneNumber, PhoneNumberConfirmed = true, Gender = model.Gender, BirthDate = model.BirthDate, City = model.City, HomeAddress = model.HomeAddress, Image = fileName
                    };
                    var result = await Manager.CreateAsync(user, model.Password);

                    //var path = Path.Combine(Server.MapPath("~/Content/Upload/"), Image.FileName);
                    //Image.SaveAs(path);
                    // model.Image = Image.FileName;

                    if (result.Succeeded)
                    {
                        //  await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        // Pour plus d'informations sur l'activation de la confirmation du compte et la réinitialisation du mot de passe, consultez http://go.microsoft.com/fwlink/?LinkID=320771
                        // Envoyer un message électronique avec ce lien
                        string code = await Manager.GenerateEmailConfirmationTokenAsync(user.Id);

                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        await Manager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                        return(RedirectToAction("Login", "Account"));
                    }
                    AddErrors(result);
                }

                // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
                return(View(model));
            }

            else
            {
                if (ModelState.IsValid)
                {
                    var user = new User {
                        UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Password = model.Password, PhoneNumber = model.PhoneNumber, PhoneNumberConfirmed = true, Gender = model.Gender, BirthDate = model.BirthDate, City = model.City, HomeAddress = model.HomeAddress, Image = model.Image
                    };

                    var result = await Manager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        //  await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                        // Pour plus d'informations sur l'activation de la confirmation du compte et la réinitialisation du mot de passe, consultez http://go.microsoft.com/fwlink/?LinkID=320771
                        // Envoyer un message électronique avec ce lien
                        string code = await Manager.GenerateEmailConfirmationTokenAsync(user.Id);

                        var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                        await Manager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                        return(RedirectToAction("Login", "Account"));
                    }
                    AddErrors(result);
                }

                // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
                return(View(model));
            }
        }
Пример #37
0
 public void Visit(int context, President president)
 {
     DoVisit(context, president);
 }