public void CreateActivity(Activity_BLL_DTO activity) { Activity a = Converter_BLL_DTO.ToActivity(activity, ctx); ctx.Activities.Add(a); ctx.SaveChanges(); }
public static Activity ToActivity(Activity_BLL_DTO activity_BLL_DTO, DataModel context) { Activity activity = new Activity(); activity.Type = Converter_BLL_DTO.ToActivityType(activity_BLL_DTO.Type, context); activity.Route = ToRoute(activity_BLL_DTO.Route, context); foreach (User_BLL_DTO us in activity_BLL_DTO.Users) { activity.Users.Add(context.Users.FirstOrDefault(x => x.Login == us.Login)); } activity.Date = activity_BLL_DTO.Date; return(activity); }
private void Add_Activity_Click(object sender, RoutedEventArgs e) { Activity_BLL_DTO activity = new Activity_BLL_DTO(); activity.Date = DateBox.SelectedDate.Value; activity.Date = TimeBox.SelectedTime.Value; activity.Type = (Sport_ComboBox.SelectedItem as ActivityType_BLL_DTO); List <Point_BLL_DTO> points = new List <Point_BLL_DTO>(); points.Add(new Point_BLL_DTO() { Latitude = (decimal)map_Page.Get_Start_DragPin.Location.Latitude, Longitude = (decimal)map_Page.Get_Start_DragPin.Location.Longitude }); for (int i = 0; i < map_Page.Get_Other_DragPins.Count; i++) { points.Add(new Point_BLL_DTO() { Latitude = (decimal)map_Page.Get_Other_DragPins[i].Location.Latitude, Longitude = (decimal)map_Page.Get_Other_DragPins[i].Location.Longitude }); } points.Add(new Point_BLL_DTO() { Latitude = (decimal)map_Page.Get_End_DragPin.Location.Latitude, Longitude = (decimal)map_Page.Get_End_DragPin.Location.Longitude }); Route_BLL_DTO route = new Route_BLL_DTO(); route.Points = points.ToArray(); route.City = (CityBox.SelectedItem as City_BLL_DTO); activity.Route = route; activity.Route.City = (CityBox.SelectedItem as City_BLL_DTO); MessageBox.Show(activity.Date.ToString() + " " + activity.Type); _bll.CreateActivity(activity); }