/// <summary> /// Projects the event onto the FullName Model provided. /// </summary> /// <typeparam name="T">Type of the Event</typeparam> /// <param name="eventData"></param> /// <param name="fullNameModel"></param> public void HandleEvent <T>(T eventData, ref NameDTO fullNameModel) where T : IEvent { var referenceHolder = new ReferenceHolder <NameDTO>(fullNameModel); _eventHandlers[eventData.GetType().Name](eventData, referenceHolder); fullNameModel = referenceHolder.Value; }
public IEnumerable <NotificationsDTO> GetNotifications([FromBody] NameDTO id)//Wade Please Review this Code, Will this work? { DesktopNotification t = new DesktopNotification() { Company = new Company(), LoginDetails = new LoginDetails() { Company = new Company(), Role = new Role() } }; t.InsertDocument(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("Company.Name", id.Name); List <CRUDAble> notes = t.SearchDocument(parameters); notes.Remove(t); t.Delete(); List <NotificationsDTO> notifications = new List <NotificationsDTO> (); foreach (DesktopNotification item in notes) { notifications.Add(new NotificationsDTO(item)); } return(notifications); }
public static NameDTO MapToDTO(NameDAO name) { var n = new NameDTO(); n.Id = name.Id; n.FirstName = name.FirstName; n.LastName = name.LastName; n.Active = name.Active; return(n); }
public static void TestDeserializeNotExpectedJSON() { using (StreamReader stream = new StreamReader($"{_baseDirectory}/resources/random-example.json")) { string json = stream.ReadToEnd(); NameDTO name = JsonSerializer.Deserialize <NameDTO>(json); Assert.Null(name.Title); Assert.Null(name.First); Assert.Null(name.Last); } }
public static void TestDeserializeJSON() { using (StreamReader stream = new StreamReader($"{_baseDirectory}/resources/name-example.json")) { string json = stream.ReadToEnd(); NameDTO name = JsonSerializer.Deserialize <NameDTO>(json); Assert.Equal("mrs", name.Title); Assert.Equal("ione", name.First); Assert.Equal("da costa", name.Last); } }
/// <summary> /// Projects an IEvent onto a model and updates the in-memory Names. /// </summary> /// <param name="eventData"></param> private static void HandleEventData(IEvent eventData) { var modelId = eventData.Id; NameDTO model; if (!_names.TryGetValue(modelId, out model)) { _nameIds.Add(modelId); model = new NameDTO(); } _modelProjector.HandleEvent(eventData, ref model); _names.AddOrUpdate(modelId, model, (key, value) => model); }
public async Task <ActionResult <Game> > PostGame([FromBody] NameDTO data) { Game game; String gameName; try { // Constructing the game object from our helper function gameName = data.gameName; game = GiantBombHelper.GetGameFromName(gameName); } catch { return(BadRequest("Invalid Game Name")); } //add the game object to database _context.Game.Add(game); await _context.SaveChangesAsync(); //Get the ID from the game (same ID from the API) string id = game.GameId; // This is needed because context are NOT thread safe, therefore we create another context for the following task. // We will be using this to insert characters into the database on a separate thread // So that it doesn't block the API. PogGamesContext tempContext = new PogGamesContext(); CharactersController characterController = new CharactersController(tempContext); // This will be executed in the background. Task addCharacters = Task.Run(async() => { // Get the list of characters from the GiantBombHelper List <Character> characters = new List <Character>(); characters = GiantBombHelper.GetCharacterFromGameId(id); foreach (Character chara in characters) { chara.GameId = id; Console.WriteLine(chara); // Add this Character to the database await characterController.PostCharacter(chara); } }); //return success code and game object return(CreatedAtAction("GetGame", new { id = game.GameId }, game)); }
/// <summary> /// Save record /// </summary> /// <returns></returns> public string SaveRecord() { var newLocation = new LocationDTO() { Street = new StreetDTO() { Name = Street }, City = City, Country = Country, Postcode = ZipCode }; var newName = new NameDTO() { Title = UserTitle, First = First, Last = Last }; var newResult = new ResultDTO() { Email = Email, Location = newLocation, Name = newName }; return(JsonConvert.SerializeObject(newResult)); }
public RedirectToRouteResult Register(CustomerDTO customer, string returnUrl, string firstName, string lastName, string email, string phone, string address1, string address2, string city, string state, string zipcode) { DataService Data = new DataService(); NameDTO Name = new NameDTO { FirstName = firstName, LastName = lastName, Active = true }; EmailDTO Email = new EmailDTO { Address = email, Active = true }; PhoneDTO Phone = new PhoneDTO { Number = phone, Active = true }; AddressDTO Address = new AddressDTO { Address1 = address1, Address2 = address2, City = city, State = state, Zipcode = int.Parse(zipcode), Active = true }; if (Data.InsertAddress(Address) && Data.InsertEmail(Email) && Data.InsertName(Name) && Data.InsertPhone(Phone)) { Name = Data.GetNames().Last(); Email = Data.GetEmails().Last(); Phone = Data.GetPhones().Last(); Address = Data.GetAddresses().Last(); CustomerDTO Customer = new CustomerDTO { Address = Address, Phone = Phone, Email = Email, Name = Name, Active = true }; if (Data.InsertCustomer(Customer)) { customer = Data.GetCustomers().Last(); Session["Customer"] = customer; return(RedirectToAction("RegisterComplete")); } } return(RedirectToAction("SignUp")); }
public HttpResponseMessage AddImageWinPEEnv(NameDTO nameDto) { _response.Content = new StringContent(new ClientImagingServices().AddImageWinPEEnv(nameDto.name), Encoding.UTF8, "text/plain"); return(_response); }
public bool InsertName(NameDTO item) { return(pssc.InsertName(NameMapper.MapToDAO(item))); }
public bool DeleteName(NameDTO item) { return(pssc.DeleteName(NameMapper.MapToDAO(item))); }
public bool ChangeName(NameDTO item) { return(pssc.ChangeName(NameMapper.MapToDAO(item))); }