Exemple #1
0
        public object DeleteBill(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string id     = dicParas.ContainsKey("id") ? dicParas["id"].ToString() : string.Empty;

                #region 验证参数
                if (string.IsNullOrEmpty(id))
                {
                    errMsg = "ID不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(id))
                {
                    errMsg = "ID须为整形";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                #endregion

                IData_BillInfoService data_BillInfoService = BLLContainer.Resolve <IData_BillInfoService>();
                int iId = Convert.ToInt32(id);
                if (!data_BillInfoService.Any(p => p.ID.Equals(iId)))
                {
                    errMsg = "该海报Id不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                var data_BillInfoModel = data_BillInfoService.GetModels(p => p.ID.Equals(iId)).FirstOrDefault <Data_BillInfo>();
                if (!data_BillInfoService.Delete(data_BillInfoModel))
                {
                    errMsg = "删除海报失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (File.Exists(data_BillInfoModel.PicturePath))
                {
                    File.Delete(data_BillInfoModel.PicturePath);
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Exemple #2
0
        public object PublishBill(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg        = string.Empty;
                string id            = dicParas.ContainsKey("id") ? dicParas["id"].ToString() : string.Empty;
                string title         = dicParas.ContainsKey("title") ? dicParas["title"].ToString() : string.Empty;
                string publishType   = dicParas.ContainsKey("publishType") ? dicParas["publishType"].ToString() : string.Empty;
                string promotionType = dicParas.ContainsKey("promotionType") ? dicParas["promotionType"].ToString() : string.Empty;
                string picturePath   = dicParas.ContainsKey("picturePath") ? dicParas["picturePath"].ToString() : string.Empty;
                string pagePath      = dicParas.ContainsKey("pagePath") ? dicParas["pagePath"].ToString() : string.Empty;

                #region 验证参数
                if (!string.IsNullOrEmpty(id) && !Utils.isNumber(id))
                {
                    errMsg = "海报ID格式不正确";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrEmpty(title))
                {
                    errMsg = "标题不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrEmpty(publishType))
                {
                    errMsg = "展示方式不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrEmpty(promotionType))
                {
                    errMsg = "活动类别不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrEmpty(pagePath))
                {
                    errMsg = "活动内容不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (title.Length > 50)
                {
                    errMsg = "标题不能超过50字";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(publishType))
                {
                    errMsg = "展示方式须为整形";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(promotionType))
                {
                    errMsg = "活动类别须为整形";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                #endregion

                Data_BillInfo         data_BillInfoModel   = new Data_BillInfo();
                IData_BillInfoService data_BillInfoService = BLLContainer.Resolve <IData_BillInfoService>();
                if (!data_BillInfoService.Any(p => p.ID.ToString().Equals(id, StringComparison.OrdinalIgnoreCase)))
                {
                    data_BillInfoModel.Title         = title;
                    data_BillInfoModel.PublishType   = Convert.ToInt32(publishType);
                    data_BillInfoModel.PromotionType = Convert.ToInt32(promotionType);
                    data_BillInfoModel.PicturePath   = picturePath;
                    data_BillInfoModel.PagePath      = pagePath;
                    data_BillInfoModel.State         = 1;
                    data_BillInfoModel.Time          = DateTime.Now;
                    data_BillInfoModel.ReleaseTime   = DateTime.Now;

                    if (!data_BillInfoService.Add(data_BillInfoModel))
                    {
                        errMsg = "发布海报失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }
                else
                {
                    data_BillInfoModel               = data_BillInfoService.GetModels(p => p.ID.ToString().Equals(id, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <Data_BillInfo>();
                    data_BillInfoModel.Title         = title;
                    data_BillInfoModel.PublishType   = Convert.ToInt32(publishType);
                    data_BillInfoModel.PromotionType = Convert.ToInt32(promotionType);
                    data_BillInfoModel.PicturePath   = picturePath;
                    data_BillInfoModel.PagePath      = pagePath;
                    data_BillInfoModel.State         = 1;
                    data_BillInfoModel.ReleaseTime   = DateTime.Now;

                    if (!data_BillInfoService.Update(data_BillInfoModel))
                    {
                        errMsg = "发布海报失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }