Esempio n. 1
0
        public static Location ToLocation(this SPWebApplication webApp, string parentId)
        {
            var id = webApp.Id;

            var uri = webApp.GetResponseUri(SPUrlZone.Default);

            string url;

            if (uri != null)
            {
                url = uri.ToString();
            }
            else
            {
                url = "No ResponseUri in default zone found.";
            }

            var location = LocationFactory.GetLocation(
                id,
                webApp.DisplayName,
                parentId,
                Scope.WebApplication,
                url,
                webApp.Sites.Count);

            return(location);
        }
        public async void UpdateComponentAsAdminNameTooLongTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap gelegen naast de glijbaan in de skillgarden van Almere");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 401 UNAUTHORIZED
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Name can not be longer than 50 characters", errorResponse.Message);
        }
        public async void UpdateComponentAsAdminDescriptionTooShortTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "X");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 400 "Description must be at least 2 characters"
            Assert.Equal(400, result.StatusCode);
            Assert.Equal("Description must be at least 2 characters", errorResponse.Message);
        }
        public async void GetAllComponentsByLocationIdTest()
        {
            Location location1 = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            Location location2 = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(2));

            // create components for location 1
            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(2, location1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(3, location1));

            //create components for location 2
            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(4, location2));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(5, location2));

            HttpRequest request = HttpRequestFactory.CreateGetRequest();

            //get all components location 1
            ObjectResult result = (ObjectResult)await this.componentController.ComponentsGetAll(request, 1);

            List <Component> components = (List <Component>)result.Value;

            // status code should be 200 OK
            Assert.Equal(200, result.StatusCode);
            // amount of found locations should be 3 for location 1
            Assert.Equal(3, components.Count);
        }
        public async void UpdateComponentAsAdminComponentNotFoundTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 5, this.adminClaim);

            ErrorResponse errorResponse = (ErrorResponse)result.Value;

            // status code should be 404 not found
            Assert.Equal(404, result.StatusCode);
            Assert.Equal(ErrorCode.COMPONENT_NOT_FOUND, errorResponse.ErrorCodeEnum);
        }
        public async void UpdateComponentAsAdminTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Fiets parcour");
            formdata.Add("Description", "Race jij het snelst door de blauwe racebaan heen?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.adminClaim);

            ComponentResponse resultComponent = (ComponentResponse)result.Value;

            // status code should be 200 OK
            Assert.Equal(200, result.StatusCode);
            Assert.Equal("Fiets parcour", resultComponent.Name);
        }
        public async void UpdateComponentAsNonAdminTest()
        {
            //create location and location
            Location location = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            await this.componentRepository.CreateAsync(ComponentFactory.CreateComponent(1, location));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Fiets parcour");
            formdata.Add("Description", "Race jij het snelst door de blauwe racebaan heen?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult resultUser = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.componentController.ComponentUpdateById(requestmessage, 1, 1, this.organiserClaim);

            ErrorResponse errorMessageUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorMessageOrganiser = (ErrorResponse)resultOrganiser.Value;

            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageOrganiser.ErrorCodeEnum);
        }
        public async void CreateNewComponentAsNonAdminTest()
        {
            //create location
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            //begin building new component
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Stippentrap");
            formdata.Add("Description", "Leg jij behendig als een antilope het stippenparcour af?");
            formdata.Add("Exercises", "1");
            AddExerciseToDatabase(1);

            HttpRequest requestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Post);

            ObjectResult resultUser = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.componentController.ComponentCreate(requestmessage, 1, this.organiserClaim);

            ErrorResponse errorResponseUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorResponseOrganiser = (ErrorResponse)resultOrganiser.Value;

            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorResponseUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorResponseOrganiser.ErrorCodeEnum);
        }
Esempio n. 9
0
        public ActionResult Location(
            RenderModel model,
            int id,
            string name)
        {
            IPublishedContent recommendationsRespository = Helper.TypedContentAtRoot().FirstOrDefault()
                                                           .FirstChild(x => x.DocumentTypeAlias == Constants.NodeAlias.RECOMMENDATIONS_REPOSITORY);

            LocationModel locationModel = LocationFactory.Create(model.Content, recommendationsRespository, Services.ContentService, Site.IsEnglish, isDetails: true);

            string expectedName = locationModel.Title.ToSeoUrl();

            string actualName = (name ?? "").ToLower();

            // permanently redirect to the correct URL
            if (expectedName != actualName)
            {
                return(RedirectToActionPermanent(Constants.Controllers.Location.NAME,
                                                 Constants.Controllers.Location.Actions.LOCATION,
                                                 new
                {
                    id = locationModel.Id,
                    name = expectedName
                }));
            }

            return(CurrentTemplate(locationModel));
        }
        public async void GetAllEventsTest()
        {
            //Create 1 location using the locationFactory
            Location locationTest = await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(1));

            //Create 2 Events using the eventFactory
            Event event1 = await this.eventRepository.CreateAsync(EventFactory.CreateEvent(1, 1, 1));

            Event event2 = await this.eventRepository.CreateAsync(EventFactory.CreateEvent(2, 1, 1));

            var test = await this.eventRepository.ListAsync();

            HttpRequest request = HttpRequestFactory.CreateGetRequest();

            ObjectResult result = (ObjectResult)await eventController.LocationGetEvents(request, locationTest.Id);

            List <EventResponse> events = (List <EventResponse>)result.Value;

            // Status code should return 200 OK
            Assert.Equal(200, result.StatusCode);
            // Count of events should equal 2
            Assert.Equal(2, events.Count);

            //Check if organisorId is the same for both
            Assert.Equal(1, event1.OrganisorId);
            Assert.Equal(1, event2.OrganisorId);
        }
Esempio n. 11
0
        public static Location ToLocation(this SPSite site, Guid parentId)
        {
            var id = site.ID;
            var activatedFeatures = site.Features.ToActivatedFeatures(id, Scope.Site, site.Url);

            string displayName;

            if (site.RootWeb != null)
            {
                displayName = site.RootWeb.Title;
            }
            else
            {
                displayName = "Site has no root web!";
            }

            var location = LocationFactory.GetLocation(
                id,
                displayName,
                parentId,
                Scope.Site,
                site.Url,
                activatedFeatures,
                site.AllWebs.Count
                );

            return(location);
        }
Esempio n. 12
0
        private static IContainer SetUp()
        {
            var container = new Container();

            container.Register(made: Made.Of(() => LocationFactory.Get()), reuse: Reuse.Singleton);
            container.RegisterDelegate <Action <string> >((r) => x => Console.WriteLine(x));
            container.RegisterDelegate <Func <string> >((r) => () => Console.ReadLine());
            container.Register <ILogger>(made: Made.Of(() => LogFactory.Get(Arg.Of <string>())), reuse: Reuse.Singleton);
            container.Register <IConfigurationProvider>(made: Made.Of(() => ConfigurationProviderFactory.Get(Arg.Of <string>())), reuse: Reuse.Singleton);
            container.Register <StationValidator>(reuse: Reuse.Singleton);
            container.Register <IStationProvider, StationProvider>(Reuse.Singleton);
            container.Register <IRadio, Radio>(Reuse.Singleton);
            container.Register <ICommand, DatabaseCommand>();
            container.Register <ICommand, HelpCommand>();
            container.Register <ICommand, ListCommand>();
            container.Register <ICommand, PauseCommand>();
            container.Register <ICommand, PlayCommand>();
            container.Register <ICommand, StartCommand>();
            container.Register <ICommand, VolumeCommand>();
            container.Register <ICommand, StopCommand>();
            container.Register <ICommand, StatusCommand>();
            container.Register <IMainLoop, MainLoop>(reuse: Reuse.Singleton);

            return(container);
        }
Esempio n. 13
0
        public void SendGetLocationButton(long id, string lang)
        {
            GenericMessage message = LocationFactory.makeLocationButton(id, lang);

            //Console.WriteLine("Location map button: " + api.SendMessageToUser(message).Result);
            api.SendMessageToUser(message);
        }
Esempio n. 14
0
        public async void UpdateLocationAsNonAdminTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(10));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden IJmuiden");
            formdata.Add("City", "IJmuiden Noord");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult resultUser = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.userClaim);

            ObjectResult resultOrganiser = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 10, this.organiserClaim);

            ErrorResponse errorMessageUser      = (ErrorResponse)resultUser.Value;
            ErrorResponse errorMessageOrganiser = (ErrorResponse)resultOrganiser.Value;

            // status code should be 403 FORBIDDEN
            Assert.Equal(403, resultUser.StatusCode);
            Assert.Equal(403, resultOrganiser.StatusCode);

            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageUser.ErrorCodeEnum);
            Assert.Equal(ErrorCode.UNAUTHORIZED_ROLE_NO_PERMISSIONS, errorMessageOrganiser.ErrorCodeEnum);
        }
Esempio n. 15
0
        public void DestroyLocation_GivenANullLocation_ThrowsArgumentException()
        {
            var locationRepository = new Mock <ILocationRepository> ();
            var locationFactory    = new LocationFactory(locationRepository.Object);

            locationFactory.DestroyLocation(null);
        }
Esempio n. 16
0
        public async void UpdateLocationAsAdminTest()
        {
            // create user
            await this.locationRepository.CreateAsync(LocationFactory.CreateLocation(5));

            // create updated user
            Dictionary <string, StringValues> formdata = new Dictionary <string, StringValues>();

            formdata.Add("Name", "Skillgarden IJmuiden");
            formdata.Add("City", "IJmuiden Noord");
            formdata.Add("Lat", "1.3214");
            formdata.Add("Lng", "1.2343");

            // create put request
            HttpRequest putrequestmessage = await HttpRequestFactory.CreateFormDataRequest(formdata, HttpMethod.Put);

            ObjectResult result = (ObjectResult)await this.locationController.LocationUpdate(putrequestmessage, 5, this.adminClaim);

            Location resultLocation = (Location)result.Value;

            // status code should be 200 OK
            Assert.Equal(200, result.StatusCode);
            // the email should be updated
            Assert.Equal("Skillgarden IJmuiden", resultLocation.Name);
        }
Esempio n. 17
0
        //private void Init()
        //{

        //    List<AndonAlertEntity> andon = AndonFactory.GetByTime();
        //    for (int i = 0; i < andon.Count; i++)
        //    {
        //        if (GridAndon.Rows.Count < andon.Count)
        //            GridAndon.Rows.Add();
        //        StationEntity Stationen = StationFactory.GetByPrimaryKey(andon[i].LOCATION_CODE);
        //        LocationEntity location = LocationFactory.GetByMasterKey(Stationen.RMES_ID);
        //        GridAndon.Rows[i].Cells[0].Value = andon[i].ANDON_ALERT_TIME.ToString("MM/dd/HH:mm");
        //        GridAndon.Rows[i].Cells[1].Value = Stationen.STATION_NAME;
        //       // GridAndon.Rows[i].Cells[2].Value = location.LOCATION_NAME;
        //        GridAndon.Rows[i].Cells[3].Value = andon[i].ANDON_ALERT_CONTENT.Substring(3, 4);
        //    }
        //}
        private void Init()
        {
            //textBox.Text = "123";
            List <AndonAlertEntity> andon = AndonFactory.GetByTime();
            string string1 = "";//, string2, string3;
            string string2 = "";
            string string3 = "";
            string string4 = "";
            string str1    = "";

            string[] str = new string[] { "", "", "" };
            for (int i = 0; i < andon.Count; i++)
            {
                StationEntity  Stationen = StationFactory.GetByPrimaryKey(andon[i].LOCATION_CODE);
                LocationEntity location  = LocationFactory.GetByMasterKey(Stationen.RMES_ID);
                TeamEntity     team      = TeamFactory.GetByTeamCode(andon[i].TEAM_CODE);
                string1 = andon[i].ANDON_ALERT_TIME.ToString("MM/dd/HH:mm");
                string2 = Stationen.STATION_NAME;
                string3 = team.TEAM_NAME;
                string4 = andon[i].ANDON_ALERT_CONTENT.ToString();
                str[i]  = string1 + " ," + string2 + string3 + string4;

                str1         = str1 + str[i] + "\r\n";
                textBox.Text = str1;
            }
        }
Esempio n. 18
0
    protected void WorkUnit_DataBinding(object sender, EventArgs e)
    {
        ASPxComboBox workUnit = sender as ASPxComboBox;
        DataTable    dt       = new DataTable();

        dt.Columns.Add("DISPLAY");
        dt.Columns.Add("VALUE");

        userManager              theUserManager = (userManager)Session["theUserManager"];
        List <LocationEntity>    locations      = LocationFactory.GetAll();
        List <ProductLineEntity> PLines         = ProductLineFactory.GetAll();

        foreach (ProductLineEntity p in PLines)
        {
            dt.Rows.Add(p.PLINE_NAME, p.RMES_ID);
        }
        foreach (LocationEntity l in locations)
        {
            dt.Rows.Add(l.LOCATION_NAME, l.RMES_ID);
        }
        workUnit.DataSource = dt;
        workUnit.ValueField = "VALUE";
        workUnit.TextField  = "DISPLAY";
        //workUnit.DataBind();
    }
Esempio n. 19
0
 protected override Location <T> Execute(CodeActivityContext context)
 {
     if (_locationFactory == null)
     {
         _locationFactory = ExpressionUtilities.CreateLocationFactory <T>(_rewrittenTree);
     }
     return(_locationFactory.CreateLocation(context));
 }
Esempio n. 20
0
 private Location <TResult> GetValueCore(ActivityContext context)
 {
     if (this.locationFactory == null)
     {
         this.locationFactory = ExpressionUtilities.CreateLocationFactory <TResult>(this.expressionTree);
     }
     return(this.locationFactory.CreateLocation(context));
 }
Esempio n. 21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var             LocationId      = 1;
            LocationFactory locationFactory = new LocationFactory();
            var             location        = locationFactory.getLocation(LocationId);
            ReviewModel     review          = new ReviewModel(location);
        }
Esempio n. 22
0
        public void CreateLocation_BlankLegalName_ThrowsArgumentException()
        {
            var locationRepository = new Mock <ILocationRepository> ();
            var locationFactory    = new LocationFactory(locationRepository.Object);
            var agency             = new Mock <Agency> ();

            locationFactory.CreateLocation(agency.Object,
                                           new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("   ")));
        }
        LocationPickerPage(IRepository repo, IRace race)
        {
            // todo - summarise the race details
            Title = race.Code;

            Picker locationpicker = new Picker { WidthRequest = 300, Title = "Locations" };
            locationpicker.Items.Clear();
            repo.LocationList.Select(l => l.Name).ForEach (locationpicker.Items.Add);

            var entry = new Entry {Placeholder = "token"};

            var button = new Button { Text = "Go!", IsEnabled = false };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            Func<bool> enable = () => (!string.IsNullOrEmpty(_token) && locationpicker.SelectedIndex >= 0 && !string.IsNullOrEmpty(locationpicker.Items[locationpicker.SelectedIndex]));

            entry.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                _token = entry.Text;
                button.IsEnabled = enable();
            };

            locationpicker.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                button.IsEnabled = enable();
            };

            button.Clicked += (object sender, EventArgs e) =>
            {
                IEnumerable<IBoat> boats = repo.BoatList;
                var location =
                    new LocationFactory()
                        .SetName(locationpicker.Items[locationpicker.SelectedIndex])
                        .SetToken(_token)
                        .SetItems(repo)
                        .Create();
                var tim = new TimingItemManager(new List<IRepository> { repo}, location, boats);
                var page = TimingMasterDetailPage.Create(tim);

                Navigation.PushAsync(page);
            };

            var dump = new Button { Text = "Dump", IsEnabled = true };
            dump.Clicked += (object sender, EventArgs e) =>
            {
                repo.Dump();
            };

            Content = new StackLayout {
                Children = {
                    locationpicker,
                    entry, button, dump
                }
            };
        }
Esempio n. 24
0
 internal override bool TryGetValue(ActivityContext context, out Location <T> value)
 {
     if (this.locationFactory == null)
     {
         this.locationFactory = ExpressionUtilities.CreateLocationFactory <T>(this.rewrittenTree);
     }
     value = this.locationFactory.CreateLocation(context);
     return(true);
 }
Esempio n. 25
0
        public static Location ToLocation(this SPWebService farm)
        {
            var id = farm.Id;

            var webAppsCount = SpLocationHelper.GetAllWebApplications().Count();

            var location = LocationFactory.GetFarm(id, webAppsCount);

            return(location);
        }
Esempio n. 26
0
        public dynamic ToJObject(Hangout hangout)
        {
            dynamic hangoutToReturn = new JObject();

            hangoutToReturn.id = Id;
            hangoutToReturn.createdByUserId = CreatedByUserId;
            hangoutToReturn.locations       = LocationFactory.ParseToJArray(hangout.Locations);

            return(hangoutToReturn);
        }
Esempio n. 27
0
 public ActionResult Edit(LocationModels model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Edit", model));
         }
         string msg = "";
         model.CreatedUser = CurrentUser.UserId;
         var result = _factory.UpdateLocation(model, ref msg);
         if (result)
         {
             HttpCookie _LocationCookie = Request.Cookies["LocCookie"];
             //if (_LocationCookie == null)
             //{
             //    HttpCookie cookie = new HttpCookie("LocCookie");
             //    cookie.Expires = DateTime.Now.AddYears(10);
             //}
             LocationFactory _facLoc = new LocationFactory();
             var             _loc    = _facLoc.GetListLocation().Select(x => new LocationSession
             {
                 Id   = x.ID,
                 Name = x.Name
             }).ToList();
             if (_loc != null && _loc.Any())
             {
                 string     myObjectJson = JsonConvert.SerializeObject(_loc); //new JavaScriptSerializer().Serialize(userSession);
                 HttpCookie cookie       = new HttpCookie("LocCookie");
                 cookie.Expires = DateTime.Now.AddYears(10);
                 cookie.Value   = Server.UrlEncode(myObjectJson);
                 Response.Cookies.Add(cookie);
             }
             return(RedirectToAction("Index"));
         }
         else
         {
             model = GetDetail(model.ID);
             if (!string.IsNullOrEmpty(msg))
             {
                 ModelState.AddModelError("Name", msg);
             }
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             return(PartialView("_Edit", model));
         }
     }
     catch (Exception ex)
     {
         NSLog.Logger.Error("Location_Edit: ", ex);
         ModelState.AddModelError("Name", ex.Message);
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(PartialView("_Edit", model));
     }
 }
Esempio n. 28
0
 public static Location ExportLocationForBeingTransported()
 {
     try
     {
         return(LocationFactory.MakeLocationForPackageInMovement());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 29
0
 public static Location ExportInstanceOfDefaultLocation()
 {
     try
     {
         return(LocationFactory.MakeDefaultLocation());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 30
0
        public void FinishRequest(string inName, string inLatitude, string inLongitude, string inDepth, string inComment)
        {
            Location location;
            double   latitude, longitude, depth;

            // validate fields
            try
            {
                // location name
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.LocationName, "name");

                // latitude
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.Latitude, "latitude");
                latitude = CommonPresenterStuff.ValidateDoubleString(_view.Latitude, "latitude");
                CommonPresenterStuff.ValidateDoubleInRange(latitude, -90.0, 90.0, "latitude");

                // longitude
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.Longitude, "longitude");
                longitude = CommonPresenterStuff.ValidateDoubleString(_view.Longitude, "longitude");
                CommonPresenterStuff.ValidateDoubleInRange(longitude, -180.0, 180.0, "longitude");

                // depth
                CommonPresenterStuff.ValidateFieldNotEmpty(_view.Depth, "depth");
                depth = CommonPresenterStuff.ValidateDoubleString(_view.Depth, "depth");
                CommonPresenterStuff.ValidateDoubleGreaterThan(depth, 0.0, "depth");
            }
            catch (Exception e)
            {
                _view.ShowErrorMessage(e.Message);
                return;
            }

            // if comment is empty, warn user
            if (_view.Comment == "")
            {
                if (!_view.WarnUser(CommonPresenterStuff.WarnFieldEmptyMessage("comment")))
                {
                    return;
                }
            }

            // try creating location
            try
            {
                location = LocationFactory.CreateLocation(inName, latitude, longitude, depth, inComment);
            }
            catch (Exception)
            {
                _view.ShowErrorMessage(CommonPresenterStuff.ErrorMessage());
                return;
            }

            Finish(location);
        }
Esempio n. 31
0
        public MotherFaker()
        {
            Dice       = new FakeDice();
            Banker     = new TraditionalBanker(new[] { 0 });
            JailRoster = new TraditionalJailRoster(Banker);
            GameBoard  = new GameBoard(Banker);
            var cardDeckFactory = new TraditionalCardDeckFactory(Banker, JailRoster, GameBoard, Dice);

            LocationFactory = new TraditionalLocationFactory(Banker, Dice, JailRoster, GameBoard, cardDeckFactory);
            GameBoard.SetLocations(LocationFactory.GetLocations(), LocationFactory.GetRailroads(), LocationFactory.GetUtilities());
        }