예제 #1
0
        /// <summary>
        ///     更新奖品
        /// </summary>
        /// <param name="member">奖品信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Update(PrizeView pvmodel, bool savePhoto = false)
        {
            PublicHelper.CheckArgument(pvmodel, "pvmodel");
            try
            {
                Prize dbmodel = PrizeContract.Prizes.SingleOrDefault(m => m.Id.Equals(pvmodel.Id));
                if (dbmodel == null)
                {
                    return(new OperationResult(OperationResultType.Error, string.Format("不存在要更新的Id为{0}的奖品", pvmodel.Id)));
                }

                dbmodel.Name        = pvmodel.Name;
                dbmodel.Description = pvmodel.Description;
                if (savePhoto)
                {
                    dbmodel.Photo = pvmodel.Photo;
                }
                dbmodel.UpdateDate = DateTime.Now;
                return(PrizeContract.Update(dbmodel));
            }
            catch (Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }
예제 #2
0
        /// <summary>
        ///     删除奖品
        /// </summary>
        /// <param name="member">奖品信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Delete(Guid guid)
        {
            try
            {
                Prize pmodel = PrizeContract.Prizes.SingleOrDefault(m => m.Id.Equals(guid));
                if (pmodel == null)
                {
                    return(new OperationResult(OperationResultType.Error, string.Format("不存在Id为{0}的奖品", guid)));
                }

                return(PrizeContract.Delete(pmodel));
            }
            catch (Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }
예제 #3
0
        /// <summary>
        ///     添加奖品
        /// </summary>
        /// <param name="prizebetting">奖品信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Add(PrizeView pvmodel)
        {
            //PublicHelper.CheckArgument(pvmodel, "pvmodel");
            Prize pmodel = new Prize
            {
                Name        = pvmodel.Name,
                Description = pvmodel.Description,
                Photo       = pvmodel.Photo,
                Member      = AccountContract.Members.SingleOrDefault(m => m.Id.Equals(pvmodel.MemberId))
            };

            try
            {
                return(PrizeContract.Add(pmodel));
            }
            catch (Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }