public JsonResult BaoMing(int eid, List <VM_Feild> info, object items = null, int on_behalf = 0, string referer = "") { var model = new ActivesModel(); model.ReadCount = (model.ReadCount ?? 0) + 1; model.ID = eid; model.SignInCount = (model.SignInCount ?? 0) + 1; SignInRecordModel signInRecordModel = new SignInRecordModel(); signInRecordModel.ActiveID = eid; signInRecordModel.CreateUserID = LoginUserInfo.ID; signInRecordModel.type = on_behalf; List <CustomFieldValueModel> list = new List <CustomFieldValueModel>(); foreach (var item in info) { CustomFieldValueModel valueModel = new CustomFieldValueModel(); valueModel.ActiveID = eid; valueModel.CreateUserID = LoginUserInfo.ID; valueModel.CustomFieldID = item.field_key.ToInt32(); valueModel.Value = item?.field_value ?? ""; list.Add(valueModel); } bool flag = SignInRecordBussiness.InserSignInRecordByTran(model, signInRecordModel, list); if (flag) { return(Success(new { info_id = signInRecordModel.ID })); } else { return(Fail("请重试")); } }
public bool InserSignInRecordByTran(ActivesModel model, SignInRecordModel signInRecordModel, List <CustomFieldValueModel> values) { SqlConnection connection = new SqlConnection(ConnStr); connection.Open(); var tran = connection.BeginTransaction(); try { Context.Update(tran, model); int id = Context.Insert(tran, signInRecordModel); values.ForEach(m => m.SignInID = id); signInRecordModel.ID = id; Context.Insert(tran, values); tran.Commit(); connection.Close(); return(true); } catch (Exception) { tran.Rollback(); connection.Close(); return(false); } }
public JsonResult UpdateActive(VM_FormModel data) { var user = UserBussiness.GetUserModel(m => m.OpenID == data.access_token); ActivesModel actives = new ActivesModel(); actives.ActiveAddress = data.address; actives.ActiveBeginTime = LeoUtils.ConvertIntDateTime1(double.Parse(data.act_start)); actives.ActiveEndTime = LeoUtils.ConvertIntDateTime1(double.Parse(data.act_end)); actives.CreateUserID = user.ID; actives.Content = data.content; actives.Img = data.banner; actives.ImgDetails = data.pics != null?string.Join(",", data.pics) : ""; actives.IsAllowCancel = data.can_quit; actives.ListReportPermission = data.visibility; actives.ListShowType = data.user_visible; actives.ManyCount = data.on_behalf_limit; actives.PromoterMobile = data.phone; actives.PromoterName = data.sign_name; actives.PromoterWechat = data.wx_no; actives.SignIntMaxCount = data.limit.ToInt32(); actives.Title = data.title; actives.can_quit = data.can_quit; actives.group_qr = data.group_qr; actives.is_public = data.is_public; actives.latitude = data.latitude; actives.longitude = data.longitude; actives.on_behalf_limit = data.on_behalf_limit; actives.queue = data.queue; actives.role = data.role; actives.user_visible = data.user_visible; actives.verify = data.verify; actives.version = data.version; actives.visibility = data.visibility; actives.ID = data.eid.ToInt32(); List <CustomFieldModel> customFieldValueModel = new List <CustomFieldModel>(); int i = 1; foreach (var item in data.req_info) { CustomFieldModel customField = new CustomFieldModel(); customField.CreateUserID = user.ID; customField.MaxTextCount = item.max_length.ToInt32(); customField.MinTextCount = item.min_length.ToInt32(); customField.Name = item.field_name; customField.PlaceHolder = item.field_desc; customField.Type = item.field_type; customField.Status = item.status.ToInt32(); customField.require = item.require; customField.Sort = i; customField.Options = item.options != null?string.Join(",", item.options) : ""; i++; customFieldValueModel.Add(customField); } bool flag = ActivesBussiness.UpdateActiveByTran(actives, customFieldValueModel); if (flag) { return(Success(new { eid = actives.ID })); } else { return(Fail("编辑失败,请重试")); } }
/// <summary> /// 活动详情 /// </summary> /// <param name="eid"></param> /// <param name="access_token"></param> /// <returns></returns> public ActionResult Detail(int eid, string access_token) { int UserID = LoginUserInfo.ID; var model = ActivesBussiness.GetActivesModel(eid); var list = CustomFieldBussiness.GetCustomFieldModels(m => m.ActiveID == eid); var signInList = SignInRecordBussiness.GetSignInRecordModels(m => m.CreateUserID == UserID && m.ActiveID == eid).OrderBy(m => m.type).ToList(); List <VM_Feild> req_info = new List <VM_Feild>(); foreach (var item in list) { VM_Feild feild = new VM_Feild(); feild.field_key = item.ID.ToString(); feild.field_desc = item.PlaceHolder; feild.field_name = item.Name; feild.field_type = item.Type.Value; feild.max_length = item.MaxTextCount.ToString(); feild.min_length = item.MinTextCount.ToString(); feild.status = item.Status.ToString(); feild.require = item.require.Value; feild.options = !string.IsNullOrEmpty(item.Options) ? item.Options.SplitExtension(",") : new string[] { }; req_info.Add(feild); } var createUser = UserBussiness.GetUserModel(model.CreateUserID.Value); model.ReadCount = (model.ReadCount ?? 0) + 1; Task.Factory.StartNew(() => { ActivesModel a = new ActivesModel() { ID = model.ID, ReadCount = model.ReadCount }; ActivesBussiness.UpdateActiveModel(a); }); int is_owner = 0; var mng = ActiveManagesBussiness.GetActiveManagesModel(m => m.ManageUserID == UserID); if (model.CreateUserID == UserID || mng != null) { is_owner = 1; } return(Success(new { cid = "", start_time = LeoUtils.ConvertDateTimeInt1(model.SigninBeginTIme).ToString(), end_time = LeoUtils.ConvertDateTimeInt1(model.SigninEndTime).ToString(), act_start = LeoUtils.ConvertDateTimeInt1(model.ActiveBeginTime).ToString(), act_end = LeoUtils.ConvertDateTimeInt1(model.ActiveEndTime).ToString(), pics = model.ImgDetails.SplitExtension(","), req_info, is_admin = model.CreateUserID == UserID, sign_name = model.PromoterName, fee = model.SignIntMaxCount != null?(model.CollectFees ?? 0 / model.SignIntMaxCount):0, status = model.SigninEndTime != null && model.SigninEndTime.Value <= DateTime.Now ? 2 : model.SigninBeginTIme != null && model.SigninBeginTIme.Value <= DateTime.Now ? 1 : 0, verify = model.verify, banner = model.Img, count = model.SignInCount, limit = model.SignIntMaxCount, address = model.ActiveAddress, latitude = !string.IsNullOrEmpty(model.latitude) ? double.Parse(model.latitude) : 0, longitude = !string.IsNullOrEmpty(model.longitude) ? double.Parse(model.longitude) : 0, on_behalf_limit = model.on_behalf_limit, queue = model.queue, role = model.role, user_visible = model.user_visible, version = model.version, visibility = model.visibility, content = model.Content, wx_no = model.PromoterWechat, owner_pic = createUser?.Avatars ?? "", title = model.Title, views = model.ReadCount ?? 0, is_owner, eid = model.ID, on_behalf = signInList.Count(), info_id = signInList.FirstOrDefault()?.ID ?? 0, phone = model.PromoterMobile, can_quit = model.can_quit, verified = signInList.FirstOrDefault()?.Status ?? 0, })); }
public static bool InserSignInRecordByTran(ActivesModel model, SignInRecordModel signInRecordModel, List <CustomFieldValueModel> values) { return(SignInRecordDAL.dal.InserSignInRecordByTran(model, signInRecordModel, values)); }
public static bool UpdateActiveByTran(ActivesModel activesModel, List <CustomFieldModel> customFieldModels) { return(ActivesDAL.dal.UpdateActiveByTran(activesModel, customFieldModels)); }
public static bool InserActiveByTran(ActivesModel signInRecordModel, List <CustomFieldModel> customFieldModels) { return(ActivesDAL.dal.InserActiveByTran(signInRecordModel, customFieldModels)); }
public static bool UpdateActiveModel(ActivesModel entity) { return(ActivesDAL.dal.UpdateActiveModel(entity)); }
public static bool InsertActiveModel(ActivesModel entity) { return(ActivesDAL.dal.InsertActiveModel(entity)); }