public AddServerResult AddServer(AddServerRequest request)
 {
     Entries.Add(request.ServerEntry);
     return(new AddServerResult {
         ServerEntry = request.ServerEntry
     });
 }
Ejemplo n.º 2
0
        public bool AddServer(AddServerRequest request)
        {
            try
            {
                bool result = false;
                using (var db = new LicenseDbEntities())
                {
                    var owner = db.LicenseOwners.FirstOrDefault(x => x.RegNom == request.RegNom);
                    if (owner != null)
                    {
                        foreach (var x in request.Servers)
                        {
                            var server = db.LicenseOwnerServers
                                         .FirstOrDefault(v => v.ServerInstance == x.ServerInstance &&
                                                         v.LicenseOwnerID == owner.Id &&
                                                         v.SendFromPC == request.ComputerName &&
                                                         v.SystemUserName == request.SystemUserName);
                            if (server == null)
                            {
                                db.LicenseOwnerServers.Add(new LicenseOwnerServer()
                                {
                                    LicenseOwnerID      = owner.Id,
                                    ServerInstance      = x.ServerInstance,
                                    ServerIPAddress     = x.ServerIPAddress,
                                    SendFromPC          = request.ComputerName,
                                    SendFromPCIPAddress = request.ComputerIP,
                                    CreateDate          = request.RequestDate,
                                    SystemUserName      = request.SystemUserName
                                });
                            }
                            else
                            {
                                server.ServerIPAddress     = x.ServerIPAddress;
                                server.SendFromPC          = request.ComputerName;
                                server.SendFromPCIPAddress = request.ComputerIP;
                                server.CreateDate          = request.RequestDate;
                                server.SystemUserName      = request.SystemUserName;
                            }
                        }

                        db.SaveChanges();

                        return(true);
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                var error = ((System.Data.Entity.Validation.DbEntityValidationException)ex).EntityValidationErrors;
                _logger.Log(LogLevel.Error, ex);

                throw;
            }
        }
Ejemplo n.º 3
0
        public AddServerResult AddServer(AddServerRequest request)
        {
            using (var context = new DataAccessContext())
            {
                var broker = context.GetDeviceBroker();

                var existing = broker.GetDeviceByName(request.ServerEntry.Server.Name);
                if (existing != null)
                {
                    throw new ArgumentException(); // TODO (CR Jun 2012): Should set the message, but it's just re-interpreted as a Fault.
                }
                var device = request.ServerEntry.ToDevice();
                broker.AddDevice(device);

                context.Commit();

                return(new AddServerResult {
                    ServerEntry = device.ToDataContract()
                });
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult Post([FromBody] AddServerRequest request)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequestWithError(ApiErrorEnum.GeneralError, ModelState));
                }

                var result = _service.AddServer(request);

                return(Ok(new AddServerResponse()
                {
                    AddedServer = result
                }));
            }
            catch (Exception ex)
            {
                _logger.Log(NLog.LogLevel.Error, ex);

                return(BadRequestWithError(ApiErrorEnum.GeneralError));
            }
        }
Ejemplo n.º 5
0
 public AddServerResult AddServer(AddServerRequest request)
 {
     return(Call(_real.AddServer, request));
 }
Ejemplo n.º 6
0
 public abstract AddServerResult AddServer(AddServerRequest request);
 public AddServerResult AddServer(AddServerRequest request)
 {
     Entries.Add(request.ServerEntry);
     return new AddServerResult { ServerEntry = request.ServerEntry };
 }
Ejemplo n.º 8
0
 public AddServerResult AddServer(AddServerRequest request)
 {
     return new AddServerResult();
 }
 public AddServerResult AddServer(AddServerRequest request)
 {
     return(new AddServerResult());
 }