Пример #1
0
        public string Get(string setting)
        {
            if (setting == "init")
            {
                _guestRepository.RemoveAllGuests();

                _guestRepository.AddGuest(new Guest()
                {
                    Id = "1", Name = "John Osborne", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now
                });
                _guestRepository.AddGuest(new Guest()
                {
                    Id = "2", Name = "Harold Wong", CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now
                });

                return("Database GuestDb was created, and collection 'Guests' was filled with 2 sample items");
            }
            else if (setting == "env")
            {
                var sb = new System.Text.StringBuilder();
                sb.AppendLine("{");
                string replaceWith = "";
                bool   foundenv    = false;

                foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
                {
                    foundenv = true;
                    var key   = de.Key.ToString().Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith).Replace("\"", replaceWith).Replace("\'", replaceWith);
                    var value = de.Value.ToString().Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith).Replace("\"", replaceWith).Replace("\'", replaceWith);
                    var clean = $"\"{key}\" : \"{value}\",";
                    sb.AppendLine(clean);
                }
                //Remove the extra comma
                if (foundenv)
                {
                    //Have to go back 2 chars to remove the comma
                    sb.Length -= 2;
                    //Re-add the new line char
                    sb.AppendLine();
                }

                sb.AppendLine("}");
                return(sb.ToString());
            }

            return("Unknown");
        }
Пример #2
0
        public GuestViewModel AddGuest(GuestViewModel model)
        {
            var guestModel = mapper.Map <Guest>(model);

            var guest = guestRepository.AddGuest(guestModel);

            return(mapper.Map <GuestViewModel>(guest));
        }
Пример #3
0
        public IActionResult Register(Guest guest)
        {
            if (ModelState.IsValid)
            {
                _guestsGuestRepository.AddGuest(guest);
                return(Success());
            }

            return(View());
        }
 public void Post([FromBody] GuestParam newGuest)
 {
     _guestRepository.AddGuest(new Guest
     {
         Id        = getrandom.Next(3, 10000).ToString(),
         Name      = newGuest.Name,
         CreatedOn = DateTime.Now,
         UpdatedOn = DateTime.Now
     });
 }
Пример #5
0
 public void AddCustomList(List <DTO.Guest> customGuests)
 {
     foreach (var guest in customGuests)
     {
         var eventGuests = _guestRepository.GetEventGuests();
         if (eventGuests == null || !eventGuests.Exists(eg => eg.Id == guest.Id))
         {
             _guestRepository.AddGuest(guest);
         }
     }
 }
Пример #6
0
        private void AddGuest()
        {
            try
            {
                Console.WriteLine("Print First_Name: ");
                string fName = Console.ReadLine();
                if (!Validation.IsNullOrEmpty(fName) || !Validation.ValidateString(fName))
                {
                    AddGuest();
                }
                Console.WriteLine("Print Last_Name: ");
                string lName = Console.ReadLine();
                if (!Validation.IsNullOrEmpty(lName) || !Validation.ValidateString(lName))
                {
                    AddGuest();
                }
                string email = Validation.ReadEmail();
                string phone = Validation.ReadPhone();
                Console.WriteLine("Print City: ");
                string city = Console.ReadLine();
                if (!Validation.IsNullOrEmpty(city) || !Validation.ValidateString(city))
                {
                    AddGuest();
                }
                Console.WriteLine("Print Country: ");
                string country = Console.ReadLine();
                if (!Validation.IsNullOrEmpty(country) || !Validation.ValidateString(country))
                {
                    AddGuest();
                }

                var guest = new Guest
                {
                    FirstName = fName,
                    LastName  = lName,
                    Email     = email,
                    Phone     = phone,
                    City      = city,
                    Country   = country,
                };

                guestService.AddGuest(guest);
                Console.WriteLine("Guest added successful");
                ConsoleGuestPresenter.Present(guestService.ReadGuests());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                AddGuest();
            }
        }
Пример #7
0
 public GuestMutation(IGuestRepository guestRepository)
 {
     Field <GuestType>(
         "createItem",
         arguments: new QueryArguments(
             new QueryArgument <NonNullGraphType <GuestInputType> > {
         Name = "guestInput"
     }
             ),
         resolve: context =>
     {
         var item = context.GetArgument <Guest>("guestInput");
         return(guestRepository.AddGuest(item));
     });
 }
Пример #8
0
 public void AddGuest(DTO.Guest newGuest)
 {
     if (EmptyFields(newGuest) == true)
     {
         return;
     }
     if (GuestExist(newGuest) == false)
     {
         _guestRepository.AddGuest(newGuest);
     }
     else
     {
         _usersMessageService.GuestExistsElert();
     }
 }
Пример #9
0
 public ViewResult RsvpForm(GuestResponse guestResponse, HttpPostedFileBase image = null)
 {
     if (ModelState.IsValid)
     {
         if (image != null)
         {
             guestResponse.ImageMimeType = image.ContentType;
             guestResponse.ImageData     = new byte[image.ContentLength];
             image.InputStream.Read(guestResponse.ImageData, 0, image.ContentLength);
         }
         ViewBag.registerState = repository.AddGuest(guestResponse);
         return(View("Thanks", guestResponse));
     }
     else
     {
         return(View());
     }
 }
Пример #10
0
 public void AddRecord(Record record)
 {
     record.Date = DateTime.Now;
     _set.AddGuest(record);
     Index();
 }