public IEnumerable <UserEventDTO> MapperToList(IEnumerable <UserEvent> userEvents) { foreach (var item in userEvents) { UserEventDTO userEventDTO = new UserEventDTO { EventId = item.EventId, UserId = item.UserId, User = new UserDTO { Id = item.User.Id, Name = item.User.Name, Email = item.User.Email }, Event = new EventDTO { Id = item.Event.Id, EventName = item.Event.EventName, EventDate = item.Event.EventDate }, Guest = item.Guest, GuestDrink = item.GuestDrink, ParticipantDrink = item.ParticipantDrink }; userEventDTOs.Add(userEventDTO); } return(userEventDTOs); }
public UserEvent MapperToEntity(UserEventDTO item) { UserEvent userEvent = new UserEvent { EventId = item.EventId, UserId = item.UserId, Guest = item.Guest, GuestDrink = item.GuestDrink, ParticipantDrink = item.ParticipantDrink }; return(userEvent); }
public static void FetchDataFromSQL(string DBServerName, string DBName, string tableToMigrate, out List <UserEventDTO> DataList) { DataList = new List <UserEventDTO>(); string ConnectionString = Utility.GetTransactionDBConnectionstring(DBServerName, DBName); try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand("logs.GetEventlogRecords", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.AddWithValue("@TableName", tableToMigrate); command.Parameters.AddWithValue("@IsDateRange", 0); connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { UserEventDTO data = new UserEventDTO { OrgId = reader["Org_id"] != DBNull.Value ? int.Parse(reader["Org_id"].ToString()) : 0, IpAddr = reader["ip"] != DBNull.Value ? reader["ip"].ToString() : string.Empty, UserId = reader["userid"] != DBNull.Value ? int.Parse(reader["userid"].ToString()) : 0, Url = reader["url"] != DBNull.Value ? reader["url"].ToString() : string.Empty, UserAgent = reader["user_agent"] != DBNull.Value ? reader["user_agent"].ToString() : string.Empty, BranchId = reader["branchid"] != DBNull.Value ? int.Parse(reader["branchid"].ToString()) : 0, EMRActionid = reader["EMRActionid"] != DBNull.Value ? int.Parse(reader["EMRActionid"].ToString()) : 0, EMRActionType = reader["EMRActiontype"] != DBNull.Value ? reader["EMRActiontype"].ToString() : string.Empty, Severity = reader["severity"] != DBNull.Value ? int.Parse(reader["severity"].ToString()) : 0, ResType = reader["restype"] != DBNull.Value ? reader["restype"].ToString() : string.Empty, ResDataJSON = reader["resdata_json"] != DBNull.Value ? reader["resdata_json"].ToString() : string.Empty, ResIds = reader["res_ids"] != DBNull.Value ? reader["res_ids"].ToString() : string.Empty, Sqlauditid = reader["sqlauditid"] != DBNull.Value ? int.Parse(reader["sqlauditid"].ToString()) : 0 }; DataList.Add(data); } } } } } catch (Exception) { throw; } }
public ActionResult Remove([FromBody] UserEventDTO userEventDTO) { try { if (userEventDTO == null) { return(NotFound()); } _applicationServiceUserEvent.Remove(userEventDTO); return(Ok()); } catch (Exception) { throw; } }
public ActionResult Post([FromBody] UserEventDTO userEventDTO) { try { if (userEventDTO == null) { return(NotFound()); } _applicationServiceUserEvent.Add(userEventDTO); return(Ok()); } catch (Exception ex) { throw ex; } }
public UserEventDTO GetEventInfo(int id) { UserEventDTO @event = _context.Events .AsNoTracking() .Where(evt => evt.Id == id) .Select(evt => new UserEventDTO { Reiteration = evt.Reiteration, UserId = evt.Calendar.UserId }) .FirstOrDefault(); if (@event == null) { return(null); } return(@event); }
public void GetEventInfo_GettingValidEvent_ShouldReturnUserEventDTO() { // Arrange Event @event = GetTestEvent(3); UserEventDTO @userEvent = new UserEventDTO() { Reiteration = @event.Reiteration, UserId = @event.Calendar.User.Id }; var eventRepository = new EventRepository(_context); // Act var actualEvent = eventRepository.GetEventInfo(3); // Assert Assert.Equal(@userEvent.UserId, actualEvent.UserId); Assert.Equal(@userEvent.Reiteration, actualEvent.Reiteration); }
public UserEventDTO MapperToDTO(UserEvent item) { UserEventDTO userEventDTO = new UserEventDTO { EventId = item.EventId, UserId = item.UserId, User = new UserDTO { Id = item.User.Id }, Event = new EventDTO { Id = item.Event.Id }, Guest = item.Guest, GuestDrink = item.GuestDrink, ParticipantDrink = item.ParticipantDrink }; return(userEventDTO); }
public void Remove(UserEventDTO eventDTO) { var obj = _mapperUserEvent.MapperToEntity(eventDTO); _serviceUserEvent.Remove(obj); }
public void Update(UserEventDTO eventDTO) { var obj = _mapperUserEvent.MapperToEntity(eventDTO); _serviceUserEvent.Update(obj); }
public void Add(UserEventDTO eventDTO) { var obj = _mapperUserEvent.MapperToEntity(eventDTO); _serviceUserEvent.Add(obj); }