public JsonResult Edit(ActivityDiscount model)
        {
            try
            {
                var businessInfo = _businessInfoService.GetById(int.Parse(Loginer.BusinessId));
                if (businessInfo == null)
                {
                    return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet));
                }


                if (model.ActivityDiscountId > 0)
                {
                    var entity = _activityDiscountService.GetById(model.ActivityDiscountId);
                    entity.Discount = model.Discount;

                    entity.EditPersonId = Loginer.AccountId;
                    entity.EditTime     = DateTime.Now;
                    //修改
                    _activityDiscountService.Update(entity);
                }
                else
                {
                    //添加
                    //model.BusinessInfoId = int.Parse(Loginer.BusinessId);
                    model.CreatePersonId     = Loginer.AccountId;
                    model.Status             = (int)EnabledEnum.效;
                    model.IsDelete           = (int)IsDeleteEnum.效;
                    model.CreateTime         = DateTime.Now;
                    model.EditPersonId       = Loginer.AccountId;
                    model.EditTime           = DateTime.Now;
                    model.ActivityDiscountId = 0;
                    model = _activityDiscountService.Insert(model);


                    businessInfo.ActivityDiscountId = model.ActivityDiscountId;
                    _businessInfoService.Update(businessInfo);
                }
            }
            catch (Exception)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public JsonResult Edit(ActivityDiscount model, int businessInfoId)
        {
            var businessInfo = _businessInfo.GetById(businessInfoId);

            if (businessInfo == null)
            {
                return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet));
            }

            //更新
            if (model.ActivityDiscountId > 0)
            {
                var activityDiscount = _activityDiscountService.GetById(model.ActivityDiscountId);
                activityDiscount.EditPersonId = Loginer.AccountId;
                activityDiscount.EditTime     = DateTime.Now;
                activityDiscount.Discount     = model.Discount;
                try
                {
                    _activityDiscountService.Update(activityDiscount);
                    return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
                }
            }//插入
            else
            {
                //添加
                model.CreatePersonId = Loginer.AccountId;
                model.EditPersonId   = Loginer.AccountId;
                model.Status         = (int)EnumHelp.EnabledEnum.效;
                model.IsDelete       = (int)EnumHelp.IsDeleteEnum.效;
                model.CreateTime     = DateTime.Now;
                model.EditTime       = DateTime.Now;
                var activityDiscount = _activityDiscountService.Insert(model);

                businessInfo.ActivityDiscountId = activityDiscount.ActivityDiscountId;
                _businessInfo.Update(businessInfo);

                return(Json(new { Status = activityDiscount.ActivityDiscountId > 0?Successed.Ok:Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult Edit(BusinessEvaluationModel model)
        {
            try
            {
                //判断数据
                if (model.Grade > 5 || model.Grade < 0)
                {
                    return(Json(new { Status = Successed.Error, Info = Successed.Error.ToString() }, JsonRequestBehavior.AllowGet));
                }
                if (model.Environment > 5 || model.Environment < 0)
                {
                    return(Json(new { Status = Successed.Error, Info = Successed.Error.ToString() }, JsonRequestBehavior.AllowGet));
                }
                if (model.Service > 5 || model.Service < 0)
                {
                    return(Json(new { Status = Successed.Error, Info = Successed.Error.ToString() }, JsonRequestBehavior.AllowGet));
                }
                if (model.Facilities > 5 || model.Facilities < 0)
                {
                    return(Json(new { Status = Successed.Error, Info = Successed.Error.ToString() }, JsonRequestBehavior.AllowGet));
                }

                //修改
                var busi = _businessInfoService.GetById(model.BusinessInfoId);
                if (busi == null)
                {
                    return(Json(new { Status = Successed.Error, Info = Successed.Error.ToString() }, JsonRequestBehavior.AllowGet));
                }
                busi.Grade = Math.Round((model.Environment + model.Service + model.Facilities) / 3, 1);


                if (model.BusinessEvaluationId > 0)
                {
                    var be = _BusinessEvaluationService.GetById(model.BusinessEvaluationId);
                    //修改
                    be.Environment = model.Environment;
                    be.Service     = model.Service;
                    be.Facilities  = model.Facilities;
                    be.EditTime    = DateTime.Now;

                    //执行更新
                    _BusinessEvaluationService.Update(be);
                }
                else
                {
                    //新增
                    BusinessEvaluation be = new BusinessEvaluation();

                    be.Environment = model.Environment;
                    be.Service     = model.Service;
                    be.Facilities  = model.Facilities;
                    be.CreateTime  = DateTime.Now;
                    be.EditTime    = DateTime.Now;

                    be = _BusinessEvaluationService.Insert(be);

                    busi.BusinessEvaluationId = be.BusinessEvaluationId;
                }

                _businessInfoService.Update(busi);
            }
            catch (Exception ex)
            {
                return(Json(new { Status = Successed.Error, Info = Successed.Error.ToString() }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Edit(BusinessInfo model)
        {
            try
            {
                if (model.BusinessInfoId > 0)
                {
                    var entity = _businessInfoService.GetById(model.BusinessInfoId);

                    //修改
                    entity.Address            = model.Address;
                    entity.AveragePay         = model.AveragePay;
                    entity.BaseAreaId         = model.BaseAreaId;
                    entity.BaseImageId        = model.BaseImageId;
                    entity.BaseLineId         = model.BaseLineId;
                    entity.BaseStationId      = model.BaseStationId;
                    entity.BusinessHour       = model.BusinessHour;
                    entity.Grade              = model.Grade;
                    entity.Introduction       = model.Introduction;
                    entity.Services           = model.Services;
                    entity.Latitude           = model.Latitude;
                    entity.Longitude          = model.Longitude;
                    entity.Mobile             = model.Mobile;
                    entity.Name               = model.Name;
                    entity.OpenDate           = string.IsNullOrWhiteSpace(model.OpenDate) ? "" : model.OpenDate;
                    entity.RefreshDate        = model.RefreshDate;
                    entity.TotalFloors        = model.TotalFloors;
                    entity.TotalRooms         = model.TotalRooms;
                    entity.BusinessTypeId     = model.BusinessTypeId;
                    entity.BusinessGroupId    = model.BusinessGroupId;
                    entity.Notic              = model.Notic;
                    entity.OrderCountPerMonth = model.OrderCountPerMonth;
                    entity.SortNo             = model.SortNo;

                    entity.EditPersonId = Loginer.AccountId;
                    entity.EditTime     = DateTime.Now;
                    _businessInfoService.Update(entity);

                    //设置距离
                    SetLocationInfo(entity);

                    return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    //if (_businessInfoService.CheckBusinessName(model.Name) > 0)
                    //    return Json(new { Status = Successed.Repeat }, JsonRequestBehavior.AllowGet);
                    //添加
                    //model.BusinessTypeId = 1;
                    model.Status         = (int)EnabledEnum.效;
                    model.IsDelete       = (int)IsDeleteEnum.效;
                    model.CreatePersonId = Loginer.AccountId;
                    model.CreateTime     = DateTime.Now;
                    model.EditPersonId   = Loginer.AccountId;
                    model.EditTime       = DateTime.Now;
                    model.OpenDate       = string.IsNullOrWhiteSpace(model.OpenDate) ? "" : model.OpenDate;
                    model = _businessInfoService.Insert(model);
                    if (model.BusinessInfoId > 0)
                    {
                        //设置距离
                        SetLocationInfo(model);

                        return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }