Exemple #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);
            }
        }
Exemple #2
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);
            }
        }