Exemplo n.º 1
0
        public int ModifySourceInstance(Common.Data.Models.SourceInstanceDto existingSourceInstance)
        {
            using (var context = new ExodusPrototype1Entities())
            {
                var matchingSourceInstance = context.SourceInstances.Find(existingSourceInstance.Id);

                if (matchingSourceInstance == null)
                {
                    return(-1);
                }

                var toCopy = SourceInstanceMapper.GetEntSourceInstanceFromDtoSourceInstance(existingSourceInstance);

                matchingSourceInstance.X      = toCopy.X;
                matchingSourceInstance.Y      = toCopy.Y;
                matchingSourceInstance.Width  = toCopy.Width;
                matchingSourceInstance.Height = toCopy.Height;
                matchingSourceInstance.WallId = toCopy.WallId;

                context.SaveChanges();
                Clients.All.SourceInstanceModified(SourceInstanceMapper.GetDtoSourceInstanceFromEntSourceInstance(matchingSourceInstance));

                this.WriteToWindowConsole($"Client: {Context.ConnectionId} - Modified Source Instance With Id: {matchingSourceInstance.Id}");

                return(matchingSourceInstance.Id);
            }
        }
 public static SourceInstance GetEntSourceInstanceFromDtoSourceInstance(Common.Data.Models.SourceInstanceDto dtoSourceInstance)
 {
     return(new SourceInstance
     {
         Id = dtoSourceInstance.Id,
         SourceId = dtoSourceInstance.SourceId,
         WallId = dtoSourceInstance.WallId,
         X = dtoSourceInstance.X,
         Y = dtoSourceInstance.Y,
         Width = dtoSourceInstance.Width,
         Height = dtoSourceInstance.Height,
     });
 }
Exemplo n.º 3
0
        public int AddSourceInstance(Common.Data.Models.SourceInstanceDto newSourceInstance)
        {
            using (var context = new ExodusPrototype1Entities())
            {
                var newSourceInstanceEnt = SourceInstanceMapper.GetEntSourceInstanceFromDtoSourceInstance(newSourceInstance);
                context.SourceInstances.Add(newSourceInstanceEnt);
                context.SaveChanges();
                Clients.All.SourceInstanceAdded(SourceInstanceMapper.GetDtoSourceInstanceFromEntSourceInstance(newSourceInstanceEnt));

                this.WriteToWindowConsole($"Client: {Context.ConnectionId} - Added Source Instance With Id: {newSourceInstanceEnt.Id}");

                return(newSourceInstanceEnt.Id);
            }
        }
Exemplo n.º 4
0
 public static DcSourceInstance GetDcSourceInstanceFromDcSourceAndDtoSourceInstance(DcSource appropriateSource, Common.Data.Models.SourceInstanceDto dtoSourceInstance)
 {
     return(new DcSourceInstance(appropriateSource, dtoSourceInstance.WallId, dtoSourceInstance.X, dtoSourceInstance.Y, dtoSourceInstance.Width, dtoSourceInstance.Height, dtoSourceInstance.Id));
 }