示例#1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebApi_Model.T_Photo_Collection GetModel(int PhotoCollectionID)
 {
     WebApi_Model.T_Photo_Collection model = dal.GetModel(PhotoCollectionID);
     if (model != null)
     {
         WebApi_BLL.T_Photo_Details tpd_bll = new T_Photo_Details();
         model.PhotoDetails = tpd_bll.GetModelList("PhotoCollectionID =" + PhotoCollectionID);
     }
     return(model);
 }
示例#2
0
        public IHttpActionResult PayPhotoCollection()
        {
            try
            {
                int PhotoCollectionID = int.Parse(requestHelper.GetRequsetForm("PhotoCollectionID", ""));
                int UID    = int.Parse(requestHelper.GetRequsetForm("UID", ""));
                int PayWay = int.Parse(requestHelper.GetRequsetForm("PayWay", ""));

                WebApi_Model.T_Photo_Collection photomodel = bll.GetModel(PhotoCollectionID);
                WebApi_BLL.T_User   tubll     = new WebApi_BLL.T_User();
                WebApi_Model.T_User usermodel = tubll.GetModel(UID);
                if (photomodel == null || photomodel.IsActive != 1)
                {
                    return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "找不到该图集")));
                }

                if (usermodel == null)
                {
                    return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "找不到该用户信息")));
                }

                WebApi_BLL.T_Photo_Pay          tppbll = new WebApi_BLL.T_Photo_Pay();
                List <WebApi_Model.T_Photo_Pay> list   = tppbll.GetModelList(" PhotoCollectionID =" + PhotoCollectionID + " and UID = " + UID);

                if (list.Count > 0)
                {
                    return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", list)));
                }
                else
                {
                    if (PayWay == 1)
                    {
                        //瞟资查看
                        if (usermodel.PiaoZi >= photomodel.PiaoZi)
                        {
                            Hashtable newSqlList = new Hashtable();
                            newSqlList.Add("update T_User Set PiaoZi = (PiaoZi - " + photomodel.PiaoZi + ") where uid = @uid", new SqlParameter[] { new SqlParameter("@uid", UID) });
                            newSqlList.Add("INSERT INTO T_Photo_Pay (photoCollectionID,UID,BuyDate,PayWay,PayValue) values (@photoCollectionID,@UID,GETDATE(),@PayWay,@PayValue)", new SqlParameter[] {
                                new SqlParameter("@photoCollectionID", PhotoCollectionID), new SqlParameter("@UID", UID), new SqlParameter("@PayWay", PayWay), new SqlParameter("@PayValue", photomodel.PiaoZi),
                            });
                            DBHelper.ExecuteSqlTranWithIndentity(newSqlList);
                            return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", true)));
                        }
                        else
                        {
                            return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "瞟资不足")));
                        }
                    }

                    else if (PayWay == 2)
                    {
                        //腿毛
                        if (usermodel.TuiMao >= photomodel.TuiMao)
                        {
                            Hashtable newSqlList = new Hashtable();
                            newSqlList.Add("update T_User Set TuiMao = (TuiMao - " + photomodel.TuiMao + ") where uid = @uid", new SqlParameter[] { new SqlParameter("@uid", UID) });
                            newSqlList.Add("INSERT INTO T_Photo_Pay (photoCollectionID,UID,BuyDate,PayWay,PayValue) values (@photoCollectionID,@UID,GETDATE(),@PayWay,@PayValue)", new SqlParameter[] {
                                new SqlParameter("@photoCollectionID", PhotoCollectionID), new SqlParameter("@UID", UID), new SqlParameter("@PayWay", PayWay), new SqlParameter("@PayValue", photomodel.TuiMao),
                            });
                            DBHelper.ExecuteSqlTranWithIndentity(newSqlList);
                            return(Ok(ReturnJsonResult.GetJsonResult(1, "OK", true)));
                        }
                        else
                        {
                            return(Ok(ReturnJsonResult.GetJsonResult(-1, "Faild", "腿毛不足")));
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                return(Ok(ReturnJsonResult.GetJsonResult(-1, "Error", ex.Message)));
            }
        }
示例#3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(WebApi_Model.T_Photo_Collection model)
 {
     return(dal.Update(model));
 }
示例#4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(WebApi_Model.T_Photo_Collection model)
 {
     return(dal.Add(model));
 }