public CarTypeModel AddCarType(CarTypeModel carTypeModel)
 {
     if (GlobalVariable.queryType == 0)
     {
         ALLCARTYPE carType = new ALLCARTYPE
         {
             carTypeID    = carTypeModel.carTypeId,
             thisCarType  = carTypeModel.carType,
             carFirm      = carTypeModel.carFirm,
             carModel     = carTypeModel.carModel,
             carDayPrice  = carTypeModel.carDayPrice,
             carLatePrice = carTypeModel.carLatePrice,
             carYear      = carTypeModel.carYear,
             carGear      = carTypeModel.carGear
         };
         DB.ALLCARTYPES.Add(carType);
         DB.SaveChanges();
         return(GetOneCarType(carType.carTypeID));
     }
     else
     {
         return(DB.AddCarType(carTypeModel.carType, carTypeModel.carFirm, carTypeModel.carModel, carTypeModel.carDayPrice, carTypeModel.carLatePrice, carTypeModel.carYear, carTypeModel.carGear).Select(ct => new CarTypeModel
         {
             carTypeId = ct.carTypeID,
             carType = ct.thisCarType,
             carFirm = ct.carFirm,
             carModel = ct.carModel,
             carDayPrice = ct.carDayPrice,
             carLatePrice = ct.carLatePrice,
             carYear = ct.carYear,
             carGear = ct.carGear
         }).SingleOrDefault());
     }
 }
예제 #2
0
        public CarTypeModel UpdateCarType(CarTypeModel carTypeModel)
        {
            _carTypes.ReplaceOne(carType => carType.carTypeId.Equals(carTypeModel.carTypeId), carTypeModel);
            CarTypeModel tmpCarTypeModel = GetOneCarType(carTypeModel.carTypeId);

            return(tmpCarTypeModel);
        }
 public CarTypeModel UpdateCarType(CarTypeModel carTypeModel)
 {
     if (GlobalVariable.queryType == 0)
     {
         ALLCARTYPE carType = DB.ALLCARTYPES.Where(ct => ct.carTypeID == carTypeModel.carTypeId).SingleOrDefault();
         if (carType == null)
         {
             return(null);
         }
         carType.carTypeID    = carTypeModel.carTypeId;
         carType.thisCarType  = carTypeModel.carType;
         carType.carFirm      = carTypeModel.carFirm;
         carType.carModel     = carTypeModel.carModel;
         carType.carDayPrice  = carTypeModel.carDayPrice;
         carType.carLatePrice = carTypeModel.carLatePrice;
         carType.carYear      = carTypeModel.carYear;
         carType.carGear      = carTypeModel.carGear;
         DB.SaveChanges();
         return(GetOneCarType(carType.carTypeID));
     }
     else
     {
         return(DB.UpdateCarType(carTypeModel.carType, carTypeModel.carFirm, carTypeModel.carModel, carTypeModel.carDayPrice, carTypeModel.carLatePrice, carTypeModel.carYear, carTypeModel.carGear, carTypeModel.carTypeId).Select(ct => new CarTypeModel
         {
             carTypeId = ct.carTypeID,
             carType = ct.thisCarType,
             carFirm = ct.carFirm,
             carModel = ct.carModel,
             carDayPrice = ct.carDayPrice,
             carLatePrice = ct.carLatePrice,
             carYear = ct.carYear,
             carGear = ct.carGear
         }).SingleOrDefault());
     }
 }
 public void AddMongoData2(BranchModel branchModel, CarTypeModel carTypeModel, CarModel carModel)
 {
     branchModel  = branchRepository.AddBranch(branchModel);
     carTypeModel = carTypeRepository.AddCarType(carTypeModel);
     carModel.carBranchIDMongo = branchModel.branchIDMongo;
     carModel.carTypeIDMongo   = carTypeModel.carTypeIdMongo;
     carModel = carsRepository.AddCar(carModel);
 }
        public static CarTypeModel ToObjectTyepId(DataRow reader)
        {
            CarTypeModel carTypeModel = new CarTypeModel();

            carTypeModel.carTypeId = int.Parse(reader[0].ToString());
            carTypeModel.carType   = reader[1].ToString();

            Debug.WriteLine("carTypeModel: " + carTypeModel.ToString());
            return(carTypeModel);
        }
예제 #6
0
 static public MySqlCommand UpdateCarType(CarTypeModel carTypeModel)
 {
     if (GlobalVariable.queryType == 0)
     {
         return(CreateSqlCommand(carTypeModel, queryCarTypeUpdate));
     }
     else
     {
         return(CreateSqlCommand(carTypeModel, procedureCarTypeUpdate));
     }
 }
예제 #7
0
        public CarTypeModel AddCarType(CarTypeModel carTypeModel)
        {
            if (_carTypes.Find <CarTypeModel>(carType => carType.carType.Equals(carTypeModel.carType)).FirstOrDefault() == null)
            {
                _carTypes.InsertOne(carTypeModel);
            }

            CarTypeModel tmpCarTypeModel = GetOneCarTypeByType(carTypeModel.carType);

            return(tmpCarTypeModel);
        }
예제 #8
0
 public HttpResponseMessage GetOneCarType(int id)
 {
     try
     {
         CarTypeModel oneCarType = carTypeRepository.GetOneCarType(id);
         return(Request.CreateResponse(HttpStatusCode.OK, oneCarType));
     }
     catch (Exception ex)
     {
         Errors errors = ErrorsHelper.GetErrors(ex);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
     }
 }
예제 #9
0
        public CarTypeModel UpdateCarType(CarTypeModel carTypeModelSql)
        {
            DataTable dt = new DataTable();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarTypeStringsMySql.UpdateCarType(carTypeModelSql));
            }
            foreach (DataRow ms in dt.Rows)
            {
                carTypeModelSql = CarTypeModel.ToObject(ms);
            }

            return(carTypeModelSql);
        }
예제 #10
0
        static private MySqlCommand CreateSqlCommand(CarTypeModel carType, string commandText)
        {
            MySqlCommand command = new MySqlCommand(commandText);

            command.Parameters.AddWithValue("@carTypeId", carType.carTypeId);
            command.Parameters.AddWithValue("@thisCarType", carType.carType);
            command.Parameters.AddWithValue("@carFirm", carType.carFirm);
            command.Parameters.AddWithValue("@carModel", carType.carModel);
            command.Parameters.AddWithValue("@carDayPrice", carType.carDayPrice);
            command.Parameters.AddWithValue("@carLatePrice", carType.carLatePrice);
            command.Parameters.AddWithValue("@carYear", carType.carYear);
            command.Parameters.AddWithValue("@carGear", carType.carGear);

            return(command);
        }
예제 #11
0
        public List <CarTypeModel> GetAllCarTypes()
        {
            DataTable           dt          = new DataTable();
            List <CarTypeModel> arrCarTypes = new List <CarTypeModel>();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarTypeStringsMySql.GetAllCarTypes());
            }
            foreach (DataRow ms in dt.Rows)
            {
                arrCarTypes.Add(CarTypeModel.ToObject(ms));
            }

            return(arrCarTypes);
        }
        public static CarTypeModel ToObject(DataRow reader)
        {
            CarTypeModel carTypeModel = new CarTypeModel();

            carTypeModel.carType      = reader[0].ToString();
            carTypeModel.carFirm      = reader[1].ToString();
            carTypeModel.carModel     = reader[2].ToString();
            carTypeModel.carDayPrice  = decimal.Parse(reader[3].ToString());
            carTypeModel.carLatePrice = decimal.Parse(reader[4].ToString());
            carTypeModel.carYear      = int.Parse(reader[5].ToString());
            carTypeModel.carGear      = reader[6].ToString();
            carTypeModel.carTypeId    = int.Parse(reader[7].ToString());

            Debug.WriteLine("carTypeModel: " + carTypeModel.ToString());
            return(carTypeModel);
        }
예제 #13
0
        public CarTypeModel GetOneCarType(int typeId)
        {
            if (typeId < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            DataTable    dt = new DataTable();
            CarTypeModel carTypeModelSql = new CarTypeModel();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(CarTypeStringsMySql.GetOneCarType(typeId));
            }
            foreach (DataRow ms in dt.Rows)
            {
                carTypeModelSql = CarTypeModel.ToObject(ms);
            }

            return(carTypeModelSql);
        }
 //[BasicAuthentication]
 //[AutorizeByRole(AutorizeByRoleAttribute.roles.Admin)]
 public HttpResponseMessage AddCarType(CarTypeModel carTypeModel)
 {
     try
     {
         HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.Created)
         {
             Content = new StringContent(JsonConvert.SerializeObject(carTypeRepository.AddCarType(carTypeModel)))
         };
         return(hrm);
     }
     catch (Exception ex)
     {
         Errors errors          = ErrorsHelper.GetErrors(ex);
         HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content = new StringContent(errors.ToString())
         };
         return(hr);
     }
 }
예제 #15
0
        public HttpResponseMessage AddCarType(CarTypeModel carTypeModel)
        {
            try
            {
                if (carTypeModel == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
                }

                CarTypeModel addedCarType = carTypeRepository.AddCarType(carTypeModel);
                return(Request.CreateResponse(HttpStatusCode.Created, addedCarType));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
            }
        }
        public void AddMongoData()
        {
            IRoleRepository roleRepository = new MongoRoleManager();

            roleRepository.AddRole(new RoleModel(0, "Guest"));
            roleRepository.AddRole(new RoleModel(1, "User"));
            roleRepository.AddRole(new RoleModel(2, "Manager"));
            roleRepository.AddRole(new RoleModel(3, "Admin"));

            bool t = true;
            bool f = false;

            BranchModel  branchModel;
            CarTypeModel carTypeModel;
            CarModel     carModel;

            branchModel  = new BranchModel("Reshon-Letzion, Reshonim, Rozhensky 10", "Reshonim", 31.9867863, 34.7707802);
            carTypeModel = new CarTypeModel("Mazda 6 Sedan", "Mazda", "M 6 Sedan", (decimal)1300.00, (decimal)263.00, 2016, "manual");
            carModel     = new CarModel(0, "4a730b5f-9299-488e-b454-6867625a7c6a.png", t, t, "20587465");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Jerusalem, Aisee, Shuk Mahane-Ehuda", "Aisee", 31.7841818, 35.2120812);
            carTypeModel = new CarTypeModel("Jaguar XF 2 Sedan", "Jaguar", "XF 2 Sedan", (decimal)2400.89, (decimal)400.00, 2012, "automatic");
            carModel     = new CarModel(0, "3c33a352-9a65-4cc3-a237-c90946fda446.png", t, t, "25825847");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Holon, Beit HaRekev 6, Nativ Ha Asara 23", "Beit HaRekev 6", 31.9722855, 34.77903);
            carTypeModel = new CarTypeModel("Skoda Rapid Sedan", "Skoda", "Rapid Sedan", (decimal)1583.23, (decimal)250.00, 2018, "hybrid");
            carModel     = new CarModel(0, "0d87e188-305e-4467-9d59-4287a9c51766.png", t, t, "2457814");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Tel Aviv, Aliyat Ha Noar, Nahelet Izhak 54", "Aliyat Ha Noar", 32.0756144, 34.8079408);
            carTypeModel = new CarTypeModel("Renault Celio Universal", "Renault", "Celio Universal", (decimal)1073.31, (decimal)252.00, 2014, "automatic");
            carModel     = new CarModel(0, "0e773d44-d4c1-44dc-a7ef-1c28c0bc6bbf.png", t, t, "1425785");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Tel Aviv, Mizpe Azrieli, Menahem Begin 132", "Mizpe Azrieli", 32.0743942, 34.794358);
            carTypeModel = new CarTypeModel("Chevrolet Spark Universal", "Chevrolet", "Spark Universal", (decimal)714.37, (decimal)28.23, 2016, "manual");
            carModel     = new CarModel(0, "3a56e46b-1645-4f25-b495-4d9ef857e5e9.png", t, t, "262531");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Ashkelon, AutoFix, HaPninim 19", "AutoFix", 31.664042, 34.6018696);
            carTypeModel = new CarTypeModel("Subaru Impreza Universal", "Subaru", "Impreza Universal", (decimal)1000.23, (decimal)123.00, 2014, "hybrid");
            carModel     = new CarModel(0, "1ff043b3-10eb-49eb-84ed-5c08d17759de.png", t, t, "25156485");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Beer Sheva, Big Center, Hevron st 21", "Big Center", 31.2438616, 34.8119657);
            carTypeModel = new CarTypeModel("Jeep Cherokee Universal", "Jeep", "Cherokee Universal", (decimal)1804.28, (decimal)200.00, 2016, "manual");
            carModel     = new CarModel(0, "0a55b13b-fdca-426f-b080-5b808189d469.png", t, t, "14785658");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Tel Aviv, Sharona Center, Nitham Sharona", "Sharona Center", 32.0724094, 34.7953738);
            carTypeModel = new CarTypeModel("Kia Sportage Universal", "Kia", "Sportage Universal", (decimal)895.36, (decimal)125.00, 2011, "automatic");
            carModel     = new CarModel(0, "1bbf1ca1-611f-4425-b147-80c705e2e8e4.png", t, t, "845742");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Beer Sheva, Ofer Geand Kanion, David Toviahu 125", "Ofer Geand Kanion", 31.2503705, 34.7717336);
            carTypeModel = new CarTypeModel("Seat Ibiza Kombi", "Seat", "Ibiza Kombi", (decimal)1583.23, (decimal)254.66, 2016, "hybrid");
            carModel     = new CarModel(0, "1dde854c-a43b-4963-9062-3f7c75982106.png", t, t, "85844487");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Reshon-Letzion, Reshonim, Rozhensky 10", "Reshonim", 31.9867863, 34.7707802);
            carTypeModel = new CarTypeModel("Peugeot NEW 308 Mini Van", "Peugeot", "NEW 308 Mini Van", (decimal)1000.23, (decimal)123.00, 2017, "automatic");
            carModel     = new CarModel(0, "2f9c06ea-5c1d-411f-a781-579fd4fed7cf.png", t, t, "208456");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Jerusalem, Aisee, Shuk Mahane-Ehuda", "Aisee", 31.7841818, 35.2120812);
            carTypeModel = new CarTypeModel("Fiat 500 Mini Van", "Fiat", "500 Mini Van", (decimal)751.57, (decimal)122.00, 2013, "manual");
            carModel     = new CarModel(0, "2eee73f6-54c7-4024-a3bf-d9aa4971b0b1.png", t, t, "35735748");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Holon, Beit HaRekev 6, Nativ Ha Asara 23", "Beit HaRekev 6", 31.9722855, 34.77903);
            carTypeModel = new CarTypeModel("Hyundai I30 Universal", "Hyundai", "I30 Universal", (decimal)891.20, (decimal)25.00, 2015, "hybrid");
            carModel     = new CarModel(0, "2c5c9a7d-ce5c-43c0-9f53-8af035e89e30.png", t, t, "346758");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Tel Aviv, Aliyat Ha Noar, Nahelet Izhak 54", "Aliyat Ha Noar", 32.0756144, 34.8079408);
            carTypeModel = new CarTypeModel("Chevrolet Impala Sedan", "Chevrolet", "Impala Sedan", (decimal)1400.00, (decimal)230.00, 2016, "automatic");
            carModel     = new CarModel(0, "3e05e08b-de89-474f-a628-7f8dd1de25df.png", t, t, "9498756");
            AddMongoData2(branchModel, carTypeModel, carModel);

            branchModel  = new BranchModel("Tel Aviv, Mizpe Azrieli, Menahem Begin 132", "Mizpe Azrieli", 32.0743942, 34.794358);
            carTypeModel = new CarTypeModel("Mazda Cx3 Universal", "Mazda", "Cx3 Universal", (decimal)891.24, (decimal)50.41, 2018, "manual");
            carModel     = new CarModel(0, "4a730b5f-9299-488e-b454-6867625a7c6a.png", t, t, "20587465");
            AddMongoData2(branchModel, carTypeModel, carModel);


            br   = branchRepository.GetAllBranches();
            ct   = carTypeRepository.GetAllCarTypes();
            cars = carsRepository.GetAllCars();

            for (int k = 0; k < cars.Count; k++)
            {
                for (int b = 0; b < br.Count; b++)
                {
                    if (cars[k].carBranchIDMongo.Equals(br[b].branchIDMongo))
                    {
                        string x = cars[k].carBranchIDMongo;
                    }

                    if (cars[k].carTypeIDMongo.Equals(ct[b].carTypeIdMongo))
                    {
                        string y = cars[k].carTypeIDMongo;
                    }
                }
            }
        }