Esempio n. 1
0
 public JsonResult DeleteCarType(int id)
 {
     using (CarTypeData db = new CarTypeData())
     {
         bool remove = db.Delete(_cartype => _cartype.id == id);
         return(Json(remove));
     }
 }
Esempio n. 2
0
    void OnClickCarType(CarTypeData typeData)
    {
        RequestCarInfo param = new RequestCarInfo
        {
            cart_type    = typeData.uid.ToString(),
            loginAccount = GameDataMgr.Instance.ResponseLogin.loginAccount
        };

        LoginManager.Instance.SendGetCarInfo <ResponseCarInfo>(param, (ret) =>
        {
            GameDataMgr.Instance.carTypeData = typeData;
            GameDataMgr.Instance.carInfo     = ret.data;
            ShowDetailWindow();
        });
    }
Esempio n. 3
0
 public JsonResult AddCarType(CarTypeValidation cartype, HttpPostedFileBase image)
 {
     if (image != null && image.ContentLength > 0)
     {
         //if supply image file save it to the server and save the path to the database
         cartype.Picture = Utilitys.GetRandomFileName("jpg");
         string _path = Path.Combine(Server.MapPath("~/Images"), cartype.Picture);
         image.SaveAs(_path);
     }
     using (CarTypeData db = new CarTypeData())
     {
         bool add = db.Add(cartype);
         return(Json(add));
     }
 }
Esempio n. 4
0
 public JsonResult GetCarType(string search)
 {
     using (CarTypeData db = new CarTypeData())
     {
         var carTypes = db.GetFromSearch(search, car => new
         {
             id           = car.id,
             model        = car.model,
             manufacturer = car.manufacturer,
             year         = car.year,
             ismanual     = car.ismanual,
             dailycost    = car.dailycost,
             latefee      = car.latefee,
             picture      = car.picture
         });
         return(Json(carTypes));
     }
 }
Esempio n. 5
0
    public void InitWith(CarTypeData typeData, Callback <CarTypeData> callback)
    {
        this.typeData = typeData;
        this.callback = callback;

        if (typeData.image.Contains("http://"))
        {
            ResourcesMgr.Instance.AsyncLoadTextureWithName(typeData.image, (texture2D) =>
            {
                if (image != null && texture2D != null)
                {
                    image.sprite = Sprite.Create(texture2D, new Rect(0.0f, 0.0f, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f), 100.0f);
                    isNew.gameObject.SetActive(false);
                }
            });
        }
        //else if(!string.IsNullOrEmpty(Enum.GetName(typeof(CarUID),typeData.uid)))
        else
        {
            string imageName = typeData.chexingcode;
            //switch ((CarUID)typeData.uid)
            //{
            //    case CarUID.SangTaNa_Old:
            //    case CarUID.SangTaNa_New:
            //        imageName = "sangtana";
            //        break;
            //    case CarUID.AiLiShe_Old:
            //    case CarUID.AiLiShe_New:
            //        imageName = "ailishe";
            //        break;
            //    case CarUID.BenTengB30_Old:
            //    case CarUID.BenTengB30_New:
            //        imageName = "bentengb30";
            //        break;
            //    case CarUID.AiLiShe2_Old:
            //    case CarUID.AiLiShe2_New:
            //        imageName = "ailishe2";
            //        break;
            //}
            Texture2D texture = ResourcesMgr.Instance.LoadTexture("CarType", imageName);
            image.sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
            isNew.gameObject.SetActive(typeData.type == 1);
        }
    }
Esempio n. 6
0
 public JsonResult UpdateCarType(CarTypeValidation cartype, HttpPostedFileBase image, int id)
 {
     //if supply image save to server
     if (image != null && image.ContentLength > 0)
     {
         if (string.IsNullOrEmpty(cartype.Picture))
         //if the car didnt had image before create new file name
         {
             cartype.Picture = Utilitys.GetRandomFileName("jpg");
         }
         string _path = Path.Combine(Server.MapPath("~/Images"), cartype.Picture);
         image.SaveAs(_path);
     }
     using (CarTypeData db = new CarTypeData())
     {
         bool update = db.Update(_cartype => _cartype.id == id, cartype);
         return(Json(update));
     }
 }