public ActionResult Register(mwc.LicensedLpAuxRegistration viewModel)
        {
            var         userPrincipal = (UserPrincipal)User;
            UserDetails userDetails   = userPrincipal.UserManager.GetUserDetailsByAccessToken(userPrincipal.AccessToken);

            JsonResponse response = new JsonResponse();

            if (ModelState.IsValid)
            {
                response.Message   = this.whitespacesManager.RegisterLicensedLpAux(viewModel, userPrincipal.AccessToken);
                response.IsSuccess = true;

                var region = mwc.CommonUtility.GetRegionByName(this.defaultRegion);
                this.RegistrationAuditor.RegionCode = region != null?Convert.ToInt32(region.RegionInformation.Id) : 0;

                this.RegistrationAuditor.TransactionId = this.RegistrationLogger.TransactionId;
                this.RegistrationAuditor.UserId        = userDetails.UserInfo.RowKey;

                if (string.Equals(response.Message, Microsoft.WhiteSpaces.Common.Constants.SuccessfullDeviceRegistration, StringComparison.OrdinalIgnoreCase))
                {
                    this.RegistrationAuditor.Audit(AuditId.DeviceRegistration, AuditStatus.Success, default(int), "Licensed LpAux incumbent registration submit by " + userDetails.UserInfo.UserName + "is successful");
                    this.RegistrationLogger.Log(TraceEventType.Information, LoggingMessageId.PortalLicensedLpAuxRegistration, "Licensed LpAux incumbent Incumbent registration submit by " + userDetails.UserInfo.UserName + "is successful");
                }
                else
                {
                    this.RegistrationAuditor.Audit(AuditId.DeviceRegistration, AuditStatus.Failure, default(int), "Licensed LpAux incumbent registration submit by " + userDetails.UserInfo.UserName + "is failed");
                    this.RegistrationLogger.Log(TraceEventType.Error, LoggingMessageId.PortalLicensedLpAuxRegistration, "Licensed LpAux incumbent Incumbent registration submit by " + userDetails.UserInfo.UserName + "is failed due to error " + response.Message);
                }
            }

            return(this.Json(response));
        }
        public ActionResult Index()
        {
            var         userPrincipal = (UserPrincipal)User;
            UserDetails userDetails   = userPrincipal.UserManager.GetUserDetailsByAccessToken(userPrincipal.AccessToken);

            var viewModel = new mwc.LicensedLpAuxRegistration
            {
                Channellist = new ChannelInfo[] { new ChannelInfo {
                                                      ChannelId = 6
                                                  }, new ChannelInfo {
                                                      ChannelId = 8
                                                  }, new ChannelInfo {
                                                      ChannelId = 9
                                                  }, new ChannelInfo {
                                                      ChannelId = 16
                                                  }, new ChannelInfo {
                                                      ChannelId = 18
                                                  }, new ChannelInfo {
                                                      ChannelId = 19
                                                  } },
                Name               = userDetails.UserInfo.FirstName + " " + userDetails.UserInfo.LastName,
                Country            = userDetails.UserInfo.Country,
                City               = userDetails.UserInfo.City,
                Email              = userDetails.UserInfo.PreferredEmail,
                Address1           = userDetails.UserInfo.Address1,
                Address2           = userDetails.UserInfo.Address2,
                Phone              = userDetails.UserInfo.Phone,
                IsRecurred         = false,
                IsReoccurenceDaily = true,
            };

            return(this.View(viewModel));
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var viewModel = new mwc.LicensedLpAuxRegistration
            {
                // default values
                IsRecurred         = false,
                IsReoccurenceDaily = true,
            };

            return(this.View(viewModel));
        }
        public void RegisterLicensedLpAux_ValidLicensedLPAuxRegistrationInfoWithAllMandatoryParameters_RegistersLicensedLPAuxSuccessfully()
        {
            MWC.LicensedLpAuxRegistration licensedLpAuxRegistration = new MWC.LicensedLpAuxRegistration
            {
                CallSign     = "BLN00751",
                Channels     = new[] { 6, 7 },
                FriendlyName = "Licensed LPAux Registration",
                StartDate    = DateTime.Today.ToString("MM-dd-yyyy"),
                EndDate      = DateTime.Today.AddDays(10).ToString("MM-dd-yyyy"),
                StartTime    = DateTime.Now.ToString("HH:mm:ss"),
                EndTime      = DateTime.Now.AddHours(2).ToString("HH:mm:ss"),
                Latitude     = "40.7779169",
                Longitude    = "-74.7922202",
            };

            string actualResponse = this.whitespacesManager.RegisterLicensedLpAux(licensedLpAuxRegistration, accessToken);

            Assert.AreEqual("Device Registered successfully.", actualResponse);
        }
        public void RegisterUnlicensedLpAux_ValidUnlicensedLPAuxRegistrationInfoWithAllMandatoryParameters_RegistersUnlicensedLPAuxSuccessfully()
        {
            MWC.LicensedLpAuxRegistration unLicensedLpAuxRegistration = new MWC.LicensedLpAuxRegistration
            {
                UlsFileNumber = "0005122780",
                Channels      = new[] { 6, 7 },
                StartDate     = DateTime.Today.ToString("MM-dd-yyyy"),
                EndDate       = DateTime.Today.AddDays(10).ToString("MM-dd-yyyy"),
                StartTime     = DateTime.Now.ToString("HH:mm:ss"),
                EndTime       = DateTime.Now.AddHours(2).ToString("HH:mm:ss"),
                Latitude      = "40.7779169",
                Longitude     = "-74.7922202",
                Name          = "Rajendra Gola",
            };

            string actualResponse = this.whitespacesManager.RegisterUnLicensedLpAux(unLicensedLpAuxRegistration, accessToken);

            Assert.AreEqual("Device Registered successfully.", actualResponse);
        }
        public void RegisterUnlicensedLpAux_ValidUnlicensedLPAuxRegistrationInfoWithReccurrenceWeekly_RegistersUnlicensedLPAuxSuccessfully()
        {
            MWC.LicensedLpAuxRegistration unLicensedLpAuxRegistration = new MWC.LicensedLpAuxRegistration
            {
                UlsFileNumber       = "0005122780",
                Channels            = new[] { 6, 7 },
                IsRecurred          = true,
                IsReoccurenceWeekly = true,
                ReoccurrenceEndDate = DateTime.Now.AddDays(28).ToString("MM-dd-yyyy"),
                WeekDaysString      = "Monday,Wednesday,Friday",
                StartDate           = DateTime.Today.ToString("MM-dd-yyyy"),
                EndDate             = DateTime.Today.ToString("MM-dd-yyyy"),
                StartTime           = DateTime.Now.ToString("HH:mm:ss"),
                EndTime             = DateTime.Now.AddHours(2).ToString("HH:mm:ss"),
                Latitude            = "40.7779169",
                Longitude           = "-74.7922202",
                Name = "Rajendra Gola",
            };

            string actualResponse = this.whitespacesManager.RegisterUnLicensedLpAux(unLicensedLpAuxRegistration, accessToken);

            Assert.AreEqual("Device Registered successfully.", actualResponse);
        }
        private List <Calendar> GetEventDates(mwc.LicensedLpAuxRegistration registrationInfo)
        {
            List <Calendar> dateList   = new List <Calendar>();
            var             strartDate = Convert.ToDateTime(registrationInfo.StartDate);
            var             endDate    = Convert.ToDateTime(registrationInfo.EndDate);

            string startTime = registrationInfo.StartTime;
            string endTime   = registrationInfo.EndTime;

            if (registrationInfo.IsReoccurenceDaily)
            {
                if (registrationInfo.ReoccurenceInstance > 0)
                {
                    for (int i = 0; i < registrationInfo.ReoccurenceInstance; i++)
                    {
                        var newStart = strartDate.AddDays(i).Add(TimeSpan.Parse(startTime));
                        var newEnd   = strartDate.AddDays(i).Add(TimeSpan.Parse(endTime));
                        dateList.Add(new Calendar {
                            Start = newStart.ToString(), End = newEnd.ToString(), Stamp = DateTime.Now.ToString()
                        });
                    }
                }
                else
                {
                    var             reoccurenceEndDate = Convert.ToDateTime(registrationInfo.ReoccurrenceEndDate);
                    List <DateTime> allDates           = new List <DateTime>();
                    for (DateTime date = strartDate; date <= reoccurenceEndDate; date = date.AddDays(1))
                    {
                        allDates.Add(date);
                    }

                    foreach (DateTime date in allDates)
                    {
                        var newStart = date.Add(TimeSpan.Parse(startTime));
                        var newEnd   = date.Add(TimeSpan.Parse(endTime));
                        dateList.Add(new Calendar {
                            Start = newStart.ToString(), End = newEnd.ToString(), Stamp = DateTime.Now.ToString()
                        });
                    }
                }
            }
            else
            {
                int i = 0;
                registrationInfo.WeekDays = registrationInfo.WeekDaysString.Split(',');
                var reoccurenceEndDate = Convert.ToDateTime(registrationInfo.ReoccurrenceEndDate);

                while (true)
                {
                    var date = strartDate.AddDays(i);
                    if (registrationInfo.WeekDays.Contains(date.DayOfWeek.ToString()))
                    {
                        var newStart = date.Add(TimeSpan.Parse(startTime));
                        var newEnd   = date.Add(TimeSpan.Parse(endTime));
                        dateList.Add(new Calendar {
                            Start = newStart.ToString(), End = newEnd.ToString(), Stamp = DateTime.Now.ToString()
                        });
                    }

                    if (registrationInfo.ReoccurenceInstance > 0)
                    {
                        if (dateList.Count == registrationInfo.ReoccurenceInstance)
                        {
                            break;
                        }
                    }
                    else if (date.Date == reoccurenceEndDate.Date)
                    {
                        break;
                    }

                    i++;
                }
            }

            return(dateList);
        }
        public string RegisterLicensedLpAux(mwc.LicensedLpAuxRegistration registrationInfo, string accessToken, string regionName = "United States")
        {
            Check.IsNotNull(registrationInfo, "Licensed LpAux Registration Info");
            Check.IsNotNull(accessToken, "Access Token");

            List <Calendar> dateList = new List <Calendar>();

            if (registrationInfo.IsRecurred)
            {
                dateList = this.GetEventDates(registrationInfo);
            }
            else
            {
                var strartDate = Convert.ToDateTime(registrationInfo.StartDate).Add(TimeSpan.Parse(registrationInfo.StartTime));
                var endDate    = Convert.ToDateTime(registrationInfo.EndDate).Add(TimeSpan.Parse(registrationInfo.EndTime));
                dateList.Add(new Calendar {
                    Start = strartDate.ToString(), End = endDate.ToString(), Stamp = DateTime.Now.ToString()
                });
            }

            Event eventTime = new Event();

            eventTime.Times    = dateList.ToArray();
            eventTime.Channels = registrationInfo.Channels;

            this.requestParams = this.GetRequestParams(
                req =>
            {
                req.AccessToken = accessToken;
                req.Params      = new Parameters
                {
                    IncumbentType = IncumbentType.LPAux.ToString(),
                    TvSpectrum    = new TvSpectrum
                    {
                        CallSign = registrationInfo.CallSign,
                        Channel  = registrationInfo.Channels[0]
                    },
                    PointsArea = new Point[] { new Point {
                                                   Latitude = registrationInfo.Latitude.ToString(), Longitude = registrationInfo.Longitude.ToString()
                                               } },
                    Event           = eventTime,
                    LPAuxRegistrant = new Whitespace.Entities.Versitcard.VCard
                    {
                        Address = new Whitespace.Entities.Versitcard.Address
                        {
                            Locality = registrationInfo.Address1,
                            Street   = registrationInfo.Address2,
                            Country  = registrationInfo.Country,
                            Region   = registrationInfo.City,
                        },
                        Org = new Whitespace.Entities.Versitcard.Organization {
                            OrganizationName = registrationInfo.ResponsibleParty
                        }
                    },
                    Contact = new Whitespace.Entities.Versitcard.VCard
                    {
                        Address = new Whitespace.Entities.Versitcard.Address
                        {
                            Locality = registrationInfo.Address1,
                            Street   = registrationInfo.Address2,
                            Country  = registrationInfo.Country,
                            Region   = registrationInfo.City,
                        },
                        Email = new Whitespace.Entities.Versitcard.Email[] { new Whitespace.Entities.Versitcard.Email {
                                                                                 EmailAddress = registrationInfo.Email
                                                                             } },
                        Title = new Whitespace.Entities.Versitcard.Title {
                            Text = registrationInfo.FriendlyName
                        },
                        Telephone = new Whitespace.Entities.Versitcard.Telephone[] { new Whitespace.Entities.Versitcard.Telephone {
                                                                                         TelephoneNumber = registrationInfo.ContactPhone, PId = registrationInfo.Phone
                                                                                     } },
                        TimeZone = registrationInfo.TimeZone
                    }

                    // Channels need to capture
                };
            });

            return(this.whitespacesClient.AddIncumbent(this.requestParams).Message);
        }