public void EditBoat(BoatModel boat)
        {
            string type;
            int    memberId;
            int    length;
            int    boatId;

            Console.Clear();
            Console.WriteLine("Edit Boat");
            Console.WriteLine("Enter member id");
            memberId = Int32.Parse(Console.ReadLine());

            while (true)
            {
                try
                {
                    Console.WriteLine("Enter boatId");
                    boatId = Int32.Parse(Console.ReadLine());
                    try
                    {
                        boat.GetBoat(memberId, boatId);
                    }
                    catch
                    {
                        Console.WriteLine("No matching boatId");
                        SafeExit();
                        return;
                    }
                    Console.WriteLine("Enter new type");
                    type = Console.ReadLine();

                    try
                    {
                        Console.WriteLine("Enter new length");
                        length = Int32.Parse(Console.ReadLine());
                    }
                    catch
                    {
                        length = 0;
                    }
                    boat.EditBoat(memberId, boatId, type, length);
                    Console.WriteLine("Boat edited");
                }
                catch (Exception)
                {
                    Console.WriteLine("No matching boatId");
                }
                SafeExit();
                break;
            }
        }
        public Task <Boat> Create(BoatModel model)
        {
            var boat = new Boat()
            {
                Name        = model.Name,
                Producer    = model.Producer,
                BuildNumber = model.BuildNumber,
                LOA         = model.LOA,
                B           = model.B,
                Picture     = model.Picture,
            };

            return(base.Create(boat));
        }
Exemple #3
0
        /// <summary>
        /// Получение полной информации по лодке
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BoatViewModel GetBoatInfo(int id)
        {
            Boat          b_result  = b_repository.Boat_GetById(id);
            BoatModel     bm_result = bm_repository.GetById(b_result.ModelId);
            List <byte[]> images    = null;
            List <Image>  i_result  = i_repository.GetAllByOwnerId(b_result.Id).ToList();

            if (i_result != null)
            {
                images = new List <byte[]>();
                foreach (Image image in i_result)
                {
                    images.Add(image.Content);
                }
            }
            List <RentViewModel> rents    = null;
            List <Rent>          r_result = r_repository.GetByOwnerId(b_result.Id).ToList();

            if (r_result != null)
            {
                rents = new List <RentViewModel>();
                foreach (Rent rent in r_result)
                {
                    rents.Add(new RentViewModel {
                        StatusFrom = rent.From, StatusTo = rent.To
                    });
                }
            }
            BoatViewModel boat = new BoatViewModel
            {
                ID               = b_result.Id,
                Type             = b_result.BoatType,
                Speed            = b_result.Speed,
                Cost             = b_result.Cost,
                Description      = b_result.Description,
                Kind             = b_result.Kind,
                Status           = b_result.Status,
                Owner            = b_result.OwnerId,
                BoatModel        = bm_result.Name,
                Lenght           = bm_result.Length,
                Width            = bm_result.Width,
                Displacement     = bm_result.Displacement,
                ManufacturerName = bm_result.ManufacturerName,
                Images           = images,
                Rents            = rents
            };

            return(boat);
        }
        private BoatModel GetBoatDetails(int id)
        {
            var boatDetails = boatRepository.GetBoatByID(id);
            var boat        = new BoatModel();

            if (boatDetails != null)
            {
                boat.BoatID       = boatDetails.ID;
                boat.Name         = boatDetails.Name;
                boat.HourlyRate   = boatDetails.HourlyRate;
                boat.IsRegistered = boatDetails.IsRegistered;
                boat.IsRented     = boatDetails.IsRented;
            }
            return(boat);
        }
Exemple #5
0
 /// <summary>
 /// Добавление новой лодки
 /// </summary>
 /// <param name="data"></param>
 /// <param name="images"></param>
 /// <returns></returns>
 public int AddBoat(BoatViewModel data)
 {
     try
     {
         if (bm_repository.GetByName(data.BoatModel) == null)
         {
             BoatModel model = new BoatModel
             {
                 Name             = data.BoatModel,
                 Length           = data.Lenght,
                 Width            = data.Width,
                 Displacement     = data.Displacement,
                 ManufacturerName = data.ManufacturerName
             };
             bm_repository.Create(model);
         }
         int  model_id = bm_repository.GetByName(data.BoatModel).Id;
         Boat boat     = new Boat
         {
             BoatType    = data.Type,
             Speed       = data.Speed,
             Cost        = data.Cost,
             Description = data.Description,
             Kind        = data.Kind,
             Status      = true,
             OwnerId     = data.Owner,
             ModelId     = model_id
         };
         int boat_id = b_repository.Boat_Create(boat);
         if (data.Images != null && data.Images.Count > 0)
         {
             foreach (byte[] content in data.Images)
             {
                 Image image = new Image
                 {
                     Content = content,
                     OwnerId = boat_id
                 };
                 i_repository.Create(image);
             }
         }
         return(0);
     }
     catch
     {
         return(1);
     }
 }
 public BoatUIEventArgs(
     RoutedEvent routedEvent,
     int id,
     string action,
     BoatModel model    = null,
     int captainId      = -1,
     string captainName = ""
     )
     : base(routedEvent)
 {
     _id          = id;
     _action      = action;
     _model       = model;
     _captainName = captainName;
     _captainId   = captainId;
 }
        public ActionResult EditBoat(BoatModel model)
        {
            if (!SessionManager.checkCurrentUserType(UserType.MAINTENANCE_PERSON))
            {
                return(new HttpStatusCodeResult(403));
            }

            if (ModelState.IsValid)
            {
                Location newLocation = MainClass.Instance.getLocations().Find(v => v.id == model.locationId);

                if (newLocation != null)
                {
                    foreach (Location l in MainClass.Instance.getLocations())
                    {
                        BL.Boat b = l.getBoats().Find(v => v.id == model.id);

                        if (b != null)
                        {
                            b.capacity     = model.capacity;
                            b.name         = model.name;
                            b.pricePerHour = model.pricePerHour;

                            if (newLocation != l)
                            {
                                if (l.removeBoat(b) && newLocation.addBoat(b) && b.saveInDB() != null)
                                {
                                    return(Redirect("/Boat/ViewBoat?locationId=" + l.id));
                                }
                                else
                                {
                                    return(View(model));
                                }
                            }
                            if (b.saveInDB() != null)
                            {
                                return(Redirect("/Boat/ViewBoat?locationId=" + l.id));
                            }
                        }
                    }
                }
            }
            ViewBag.Status  = false;
            ViewBag.Message = "Could not edit boat";
            return(View(model));
        }
Exemple #8
0
        public void ChainOfResponsibility([FromServices] IVehicleService service)
        {
            var car = new CarModel
            {
                Wheels    = 4,
                HasEngine = true
            };

            service.InsertVehicleModel(car);

            var boat = new BoatModel
            {
                Wheels   = 3,
                CanFloat = false
            };

            service.InsertVehicleModel(boat);
        }
Exemple #9
0
        public ActionResult Index()
        {
            //Summary
            //Initialized the List Object for Boat Model
            List <BoatModel> list = new List <BoatModel>();

            try
            {
                //Declared an Arrayto type String for specifying and declaring the different boat types
                string[] boatType = { "Speed Boat", "Cargo Boat", "Sail Boat" };

                //Declared an Array of type Integer for specifying and declaring the different boat speeds
                int[] boatSpeed = { 30, 15, 5 };

                //Declared a variable randomId for Dynamic random Number of Boats to be generated
                int randomId = new Random().Next(3, 5);

                //Declared a variable of type Integer i.e. randomBoatType
                //for Dynamic random type of Boats to be generated
                int randomBoatType /*= new Random().Next(0, 2)*/;

                //Declared For Loop for creating thhe Boat Object that will be iterated based
                //On te value of randomId
                for (int i = 0; i < randomId; i++)
                {
                    BoatModel boatObject = new BoatModel();
                    randomBoatType   = new Random().Next(0, 2);
                    boatObject.Type  = boatType[randomBoatType];
                    boatObject.Speed = boatSpeed[randomBoatType];
                    list.Add(boatObject);
                }
            }
            catch (Exception ex)
            {
                exceptionLogger.Error("Exception Message:- " + ex.Message
                                      + Environment.NewLine +
                                      "Inner Exception Message:- " + ex.InnerException
                                      + Environment.NewLine
                                      + "Stack Trace:- " + ex.StackTrace
                                      + Environment.NewLine
                                      + "Exception Source:- " + ex.Source);
            }
            return(View(list));
        }
Exemple #10
0
    private void loadResources()
    {
        river      = new RiverModel();
        boat       = new BoatModel();
        leftCoast  = new CoastModel("leftCoast");
        rightCoast = new CoastModel("rightCoast");
        characters = new CharacterModel[6];

        for (int i = 0; i < 3; i++)
        {
            characters[i] = new CharacterModel("priest");
            characters[i].setPosOnCoast(rightCoast.getVacantIndex());
        }
        for (int i = 3; i < 6; i++)
        {
            characters[i] = new CharacterModel("devil");
            characters[i].setPosOnCoast(rightCoast.getVacantIndex());
        }
    }
        public void AddBoat(BoatModel boat)
        {
            int    memberId;
            string type;
            int    length;

            Console.Clear();
            Console.WriteLine("Add new boat");
            Console.WriteLine("Enter member id");
            memberId = Int32.Parse(Console.ReadLine());

            Console.WriteLine("1: Sailboat | 2: Motorboat | 3: Kayak/Canoe | 4: Others");
            type = Console.ReadLine();

            if (type == "1")
            {
                type = "Sailboat";
            }
            else if (type == "2")
            {
                type = "Motorboat";
            }
            else if (type == "3")
            {
                type = "Kayak/Canoe";
            }
            else if (type == "4")
            {
                type = "Other";
            }
            else
            {
                Console.WriteLine("Not a valid type");
            }

            Console.WriteLine("Enter length");
            length = Int32.Parse(Console.ReadLine());

            boat.AddBoat(memberId, type, length);
            Console.WriteLine("Boat added");
        }
Exemple #12
0
    public void LoadResource()
    {
        for (int i = 0; i < 3; i++)
        {
            RoleModel priest = new RoleModel("priest");
            priest.SetName("priest" + i);
            priest.SetPosition(new Vector3(5 + i * 0.5F, 0, 0));
            Priests[i] = priest;

            RoleModel devil = new RoleModel("devil");
            devil.SetName("devil" + i);
            devil.SetPosition(new Vector3(7 + i * 0.5F, -0.1F, 0));
            devil.Idle();
            Devils[i] = devil;
        }

        RightLand = new LandModel("right");
        LeftLand  = new LandModel("left");
        River     = new RiverModel();
        Boat      = new BoatModel();
    }
Exemple #13
0
        public void VerboseList(MemberModel member, BoatModel boat)
        {
            Console.Clear();

            IEnumerable <MemberModel> members = member.ShowAllMembers();

            foreach (var m in members)
            {
                Console.WriteLine("ID: {0}, Name: {1}, Birthday: {2}", m.MemberId, m.FullName, m.Birthday);

                foreach (var b in m.Boats)
                {
                    Console.WriteLine("Boat ID: {0}", b.BoatId);
                    Console.WriteLine("Boat Type: {0}", b.BoatType);
                    Console.WriteLine("Boat Length: {0} ft", b.Length);
                    Console.WriteLine("---------------------");
                }

                Console.WriteLine("---------------------");
            }
            SafeExit();
        }
Exemple #14
0
 public void LoadResources()
 {
     water     = new Water();
     startLand = new LandModel("start");
     endLand   = new LandModel("end");
     boat      = new BoatModel();
     roles     = new RoleModel[6];
     for (int i = 0; i < 3; i++)
     {
         RoleModel role = new RoleModel("priest", startLand.GetEmptyPosition());
         role.SetName("priest" + i);
         startLand.AddRole(role);
         roles[i] = role;
     }
     for (int i = 0; i < 3; i++)
     {
         RoleModel role = new RoleModel("devil", startLand.GetEmptyPosition());
         role.SetName("devil" + i);
         startLand.AddRole(role);
         roles[i + 3] = role;
     }
 }
        public ActionResult AddBoat(BoatModel boatModel)
        {
            if (!SessionManager.checkCurrentUserType(UserType.MAINTENANCE_PERSON))
            {
                return(new HttpStatusCodeResult(403));
            }

            boatModel.locationList = BL.MainClass.Instance.getLocations();
            boatModel.file.SaveAs(Server.MapPath("~/Public/Images/") + boatModel.file.FileName);
            boatModel.imagePath = boatModel.file.FileName;

            // string path = Path.Combine(Server.MapPath("~/Public/Images"), Path.GetFileName(boatModel.file.FileName));
            //boatModel.ImageFile.SaveAs(path);

            string fileName = boatModel.file.FileName;
            //string extension = Path.GetExtension(boatModel.file.FileName);
            //fileName = fileName + extension;
            string imagePath = "Public/Images/" + fileName;

            if (ModelState.IsValid)
            {
                BL.Location location = MainClass.Instance.getLocations().Find(v => v.id == boatModel.locationId);

                if (location != null)
                {
                    if (location.addBoat(new BL.Boat(boatModel.name, boatModel.capacity, boatModel.pricePerHour, boatModel.seasonId, imagePath)))
                    {
                        ViewBag.Status  = true;
                        ViewBag.Message = "Boat added successfully";

                        return(View(boatModel));
                    }
                }
            }
            ViewBag.Status  = false;
            ViewBag.Message = "Boat could not be added. Please make sure that you select a location.";
            return(View(boatModel));
        }
        public void RemoveBoat(BoatModel boat)
        {
            int memberId;
            int boatId;

            Console.Clear();
            Console.WriteLine("Remove Boat");
            Console.WriteLine("Enter member id");
            memberId = Int32.Parse(Console.ReadLine());

            while (true)
            {
                try
                {
                    Console.WriteLine("Enter boatId");
                    boatId = Int32.Parse(Console.ReadLine());
                    try
                    {
                        boat.RemoveBoat(memberId, boatId);
                        break;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("No matching boatId");
                        SafeExit();
                        return;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("No matching boatId");
                    SafeExit();
                    return;
                }
            }
            Console.WriteLine("Boat removed");
            SafeExit();
        }
        public void TestAddBoat()
        {
            bool      result    = false;
            BoatModel boatModel = new BoatModel {
                name = "boat 1", capacity = 300, pricePerHour = 30, seasonId = 1, imagePath = "Public/images"
            };
            LatLongCoordinate point = new LatLongCoordinate(5, 4, "asd");

            point.saveInDB();
            // Get location
            Location location = MainClass.Instance.getLocations().Find(v => v.id == 3007);

            if (MainClass.Instance.addLocation(new Location(point, location.name)))
            {
                if (location != null)
                {
                    if (location.addBoat(new Boat(boatModel.name, boatModel.capacity, boatModel.pricePerHour, boatModel.seasonId, boatModel.imagePath)))
                    {
                        result = true;
                    }
                }
            }
            Assert.IsTrue(result);
        }
Exemple #18
0
 public BoatModel boat; //点击Boat
 public void setBoatModel(BoatModel obj)
 {
     boat = obj;
 }
Exemple #19
0
 public void SetBoat(BoatModel boat)
 {
     this.boat = boat;
 }
Exemple #20
0
 public void GoBoat(BoatModel boat)
 {
     role.transform.parent = boat.GetBoat().transform;
     land_model            = null;
     on_boat = true;
 }
 public void GoBoat(BoatModel boat)//登上船
 {
     role.transform.parent = boat.GetBoat().transform;
     bank_model            = null;
     on_boat = true;
 }
Exemple #22
0
 //实例化的同时同步对象
 public Judge(CoastModel start, CoastModel end, BoatModel b)
 {
     startCoast = start;
     endCoast   = end;
     boat       = b;
 }
Exemple #23
0
 public Judge(LandModel start_, LandModel end_, BoatModel boat_)
 {
     start = start_;
     end   = end_;
     boat  = boat_;
 }
Exemple #24
0
 public void GoBoat(BoatModel boat)
 {
     role.transform.parent = boat.GetBoat().transform;
     onBoat = true;
 }
Exemple #25
0
 public Judge(BoatModel b)
 {
     boat = b;
 }
Exemple #26
0
 public BoatController(MySceneActionManager am)
 {
     actionManager = am;
     model         = new BoatModel();
 }