public void Save(BadgeDTO badge) { using (var context = new CoffeMachineDbContext()) { BadgeModel model = badge.ToModel(); context.Badges.Add(model); context.SaveChanges(); } }
private void RadioButton_Checked(object sender, RoutedEventArgs e) { Canvas c = this.BadgeScreen; //http://classicalprogrammer.wikidot.com/don-t-delete-an-element-from-collection-in-foreach-loop for (int inx = c.Children.Count - 1; inx >= 0; inx--) { if (c.Children[inx] is Label || c.Children[inx] is Line) { c.Children.Remove(c.Children[inx]); } } this.imgCanvas.Source = new BitmapImage(); BadgeDTO selected = this._badgeVM.SelectedBadge; this.BadgeScreen.Background = Brushes.White; this.BadgeScreen.AllowDrop = true; this.BadgeScreen.Drop += new DragEventHandler(Drag_Drop); this.BadgeScreen.DragEnter += new DragEventHandler(Drag_DragEnter); this.BadgeScreen.Width = selected.Width; this.BadgeScreen.Height = selected.Height; this.widthBadge = selected.Width; this.heightBadge = selected.Height; this._badgeVM.SelectedTemplate = selected.Template; //CHECK IN THE DB IF A BADGE IN POSITION NOT ALREADY EXISTS, IF EXISTS SHOW IT List <PositionSet> myPositions = this._badgeVM.GetPositions(selected.ID, this._idEvent, selected.Template); foreach (PositionSet p in myPositions) { Label label = new Label(); label.Content = p.FieldSet.Name; label.FontFamily = ALLFONTS.Where(font => font.ToString().Equals(p.FontFamily)).FirstOrDefault(); label.FontSize = p.FontSize; label.MouseMove += new MouseEventHandler(Label_MouseMove); label.PreviewMouseRightButtonDown += new MouseButtonEventHandler(Label_RightClick); label.AllowDrop = true; label.Drop += new DragEventHandler(Drag_Drop); label.DragEnter += new DragEventHandler(Drag_DragEnter); var child = this.BadgeScreen.Children.OfType <Label>().Where(la => la == label).FirstOrDefault(); if (child != null) { c.Children.Remove(child); } c.Children.Add(label); Canvas.SetLeft(label, p.Position_X); Canvas.SetTop(label, p.Position_Y); } }
public static BadgeModel ToModel(this BadgeDTO source) { if (source == null) { return(null); } return(new BadgeModel { ID = source.BadgeID, OrderList = source.OrderList.Select(o => o.ToModel()).ToList() }); }
/// <summary> /// Converts this instance of <see cref="Badge"/> to an instance of <see cref="BadgeDTO"/>. /// </summary> /// <param name="entity"><see cref="Badge"/> to convert.</param> public static BadgeDTO ToDTO(this Badge entity) { if (entity == null) { return(null); } var dto = new BadgeDTO(); dto.ID = entity.ID; dto.Number = entity.Number; dto.IsActive = entity.IsActive; dto.CreatedByUserID = entity.CreatedByUserID; dto.CreatedDate = entity.CreatedDate; dto.ModifiedByUserID = entity.ModifiedByUserID; dto.ModifiedDate = entity.ModifiedDate; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="BadgeDTO"/> to an instance of <see cref="Badge"/>. /// </summary> /// <param name="dto"><see cref="BadgeDTO"/> to convert.</param> public static Badge ToEntity(this BadgeDTO dto) { if (dto == null) { return(null); } var entity = new Badge(); entity.ID = dto.ID; entity.Number = dto.Number; entity.IsActive = dto.IsActive; entity.CreatedByUserID = dto.CreatedByUserID; entity.CreatedDate = dto.CreatedDate; entity.ModifiedByUserID = dto.ModifiedByUserID; entity.ModifiedDate = dto.ModifiedDate; dto.OnEntity(entity); return(entity); }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="Badge"/> converted from <see cref="BadgeDTO"/>.</param> static partial void OnEntity(this BadgeDTO dto, Badge entity);
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="BadgeDTO"/> converted from <see cref="Badge"/>.</param> static partial void OnDTO(this Badge entity, BadgeDTO dto);
public bool UpdateBadge(int badgeID, BadgeDTO badgeDTO) { throw new NotImplementedException(); }
public int CreateBadge(BadgeDTO badgeDTO) { throw new NotImplementedException(); }