public string CreateStamp(DUETContext db, dynamic _stamp, dynamic _inspiration) { try { CurrentStamp = new Stamp(db, Id, _stamp, _inspiration); CurrentStamp.Save(db); Stamps.Add(CurrentStamp); return(CurrentStamp.CreateBitmap(db, this)); } catch (Exception exception) { return("Error 2: " + exception.Message); } }
public Stamp(DUETContext db, int Id, dynamic _stamp, dynamic _inspiration) { DesignId = Id; String title = _inspiration.title; InspirationId = Inspiration.Get(db, title); X = _inspiration.x; Y = _inspiration.y; InspirationWidth = _inspiration.width; InspirationHeight = _inspiration.height; Width = _stamp.width; Height = _stamp.height; int index = _stamp.shapeindex; Shape = Stamp.GetShape(index); Type = _stamp.type; Scale = _stamp.scale; Rotate = _stamp.rotate; Red = _stamp.r; Green = _stamp.g; Blue = _stamp.b; Used = false; }
public string CopyDesign(DUETContext db, int designid) { try { if (Saved == false) { var copydesign = db.Designs.Where(d => d.Id == designid) .Include(d => d.Member) .Include(d => d.Processes) .ThenInclude(p => p.Stamp).First(); if (copydesign == null) { return("Error in Design Copy: No design found to copy."); } else { Width = copydesign.Width; Height = copydesign.Height; Red = copydesign.Red; Green = copydesign.Green; Blue = copydesign.Blue; Processes = new List <Proces>(); Stamps = new List <Stamp>(); //db.Designs.Update(this); var laststampid = -1; foreach (var copyProces in copydesign.Processes) { Proces proces = new Proces(); proces.DesignId = Id; proces.Index = copyProces.Index; proces.X = copyProces.X; proces.Y = copyProces.Y; if (copyProces.StampId != laststampid) { var stamp = new Stamp(); stamp.DesignId = Id; stamp.InspirationId = copyProces.Stamp.InspirationId; stamp.InspirationWidth = copyProces.Stamp.InspirationWidth; stamp.InspirationHeight = copyProces.Stamp.InspirationHeight; stamp.Width = copyProces.Stamp.Width; stamp.Height = copyProces.Stamp.Height; stamp.X = copyProces.Stamp.X; stamp.Y = copyProces.Stamp.Y; stamp.Type = copyProces.Stamp.Type; stamp.Shape = copyProces.Stamp.Shape; stamp.Scale = copyProces.Stamp.Scale; stamp.Rotate = copyProces.Stamp.Rotate; stamp.Red = copyProces.Stamp.Red; stamp.Green = copyProces.Stamp.Green; stamp.Blue = copyProces.Stamp.Blue; stamp.Used = true; Stamps.Add(stamp); db.Stamps.Add(stamp); db.SaveChanges(); // deze moet anders heb je geen stampId in je proces laststampid = copyProces.StampId; } proces.StampId = laststampid; db.Processes.Add(proces); } db.SaveChanges(); } return(GetDesignData(db, designid)); } else { return("Error in Design Copy: Your design is already saved. First create a new Design."); } } catch (Exception exception) { return("Error in Design Copy: " + exception.Message); } }