public JsonResult Get(int id)
        {
            var result = DBCarServiceDL_CLIENT.ClientByID(id);

            if (result == null)
            {
                return(new JsonResult(new ResponsModel()
                {
                    status = false, description = "not found"
                }));
            }
            return(new JsonResult(result));
        }
        public JsonResult Post([FromBody] JObject value)
        {
            ClientModel candidat = new ClientModel()
            {
                name      = value["name"].ToString(),
                birthDate = Convert.ToDateTime(value["b_date"].ToString()),
                email     = value["email"].ToString(),
                lastName  = value["last_name"].ToString(),
                phone     = value["phone"].ToString()
            };

            int UID = DBCarServiceDL_CLIENT.ClientADD(candidat);

            CarModel candidatCar = new CarModel()
            {
                brand       = value["brand"].ToString(),
                mileage     = Convert.ToInt32(value["mileageCar"].ToString()),
                model       = value["model"].ToString(),
                stateNumber = value["stateNumber"].ToString(),
                VIN         = value["vinNumber"].ToString(),
                yearOfIssue = Convert.ToDateTime(value["yearOfIssue"].ToString()),
                clientID    = UID
            };

            int CID = DBCarServiceDL_CAR.AddCar(candidatCar);

            var result = DBCarServiceDL_CLIENT.ClientByID(UID);

            if (result != null)
            {
                return(new JsonResult(new ResponsModel()
                {
                    status = true
                }));
            }
            else
            {
                return(new JsonResult(new ResponsModel()
                {
                    status = false, description = "adding failed"
                }));
            }
        }
示例#3
0
        public JsonResult Post([FromBody] JObject value)
        {
            CarModel candidat = new CarModel()
            {
                brand       = value[""].ToString(),
                mileage     = Convert.ToInt32(value[""].ToString()),
                model       = value[""].ToString(),
                stateNumber = value[""].ToString(),
                VIN         = value[""].ToString(),
                yearOfIssue = Convert.ToDateTime(value[""].ToString()),
                clientID    = Convert.ToInt32(value[""].ToString())
            };

            var search = DBCarServiceDL_CLIENT.ClientByID(candidat.clientID);

            if (search == null)
            {
                return(new JsonResult(new ResponsModel()
                {
                    status = false, description = "client not found"
                }));
            }
            else
            {
                var resul = DBCarServiceDL_CAR.AddCar(candidat);
                if (resul > 0)
                {
                    return(new JsonResult(new ResponsModel()
                    {
                        status = true
                    }));
                }
                else
                {
                    return(new JsonResult(new ResponsModel()
                    {
                        status = false, description = "adding failed"
                    }));
                }
            }
        }