public ActionResult Edit(CrowdCateViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { CrowdCate entity = new CrowdCate(); entity.ID = model.ID; entity.CateName = model.CateName; CrowdCateService.Update(entity); result.Message = "编辑人群分类成功!"; LogHelper.WriteLog("编辑人群分类成功"); return(RedirectToAction("index")); } catch (DbEntityValidationException ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加人群分类错误", ex); return(View(model)); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return(View(model)); } }
public ActionResult Logo(CompanyLogoViewModel model) { ViewBag.MenuItem = "shop-logo"; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; var member = MemberService.Find(CookieHelper.MemberID); if (member.Status < (int)MemberStatus.CompanyAuth) { return(Redirect(Url.Action("openbiz", "reg"))); } if (ModelState.IsValid) { try { CompanyService.SaveLogo(CookieHelper.MemberID, model); result.Message = "企业标志保存成功!"; return(RedirectToAction("Logo")); } catch (Exception ex) { result.Message = "企业标志保存失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "企业标志保存失败!", ex); return(View(model)); } } else { result.Message = "表单输入有误,请仔细填写表单!"; result.AddServiceError("表单输入有误,请仔细填写表单!"); } return(View(model)); }
public ActionResult Edit(DepartmentViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { Department entity = new Department(); entity.ID = model.ID; entity.Name = model.Name; entity.Description = model.Description; entity.Leader = model.Leader; DepartmentService.Update(entity); result.Message = "编辑部门成功!"; LogHelper.WriteLog("编辑部门成功"); return(RedirectToAction("index")); } catch (DbEntityValidationException ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加部门错误", ex); return(View(model)); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return(View(model)); } }
public ActionResult Edit(EditViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; List <int> GroupList = new List <int>(); GroupList.Add(model.GroupID); var groups = GetForeignData(GroupList); ViewBag.Data_GroupID = groups; if (ModelState.IsValid) { try { MemberService.Update(model); result.Message = "添加会员信息成功!"; LogHelper.WriteLog("添加会员信息成功"); return(RedirectToAction("index")); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加会员信息错误", ex); return(View(model)); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return(View(model)); } }
public ActionResult AddFavorite(int id) { ServiceResult result = new ServiceResult(); var MemberID = CookieHelper.MemberID; if (!FavoriteService.GetALL().Any(x => x.MemberID == MemberID && x.MediaID == id)) { try { Favorite entity = new Favorite() { MediaID = id, MemberID = MemberID, AddTime = DateTime.Now }; FavoriteService.Create(entity); } catch (Exception ex) { result.Message = "添加收藏失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "添加收藏失败!", ex); } } else { result.Message = "已经收藏了该媒体"; result.AddServiceError("已经收藏了该媒体"); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ServiceResult GenerateTempTeam(Team newTeam) { var result = new ServiceResult(); try { ITeamService teamService = new TeamService(_repository); if (!teamService.CheckTeamNameForDirtyWords(newTeam.Name)) { result.AddServiceError("TeamName", "Team name contains a naughty word."); } else { if (teamService.CheckTeamNameAvailability(newTeam.EventId, newTeam.Name)) { newTeam.Code = teamService.GenerateTeamCode(newTeam.EventId); } else { result.AddServiceError("TeamName", "Team name is already taken for this event."); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ActionResult BaseInfo(ProfileViewModel model) { ViewBag.MenuItem = "baseinfo"; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { MemberService.SaveMemberProfile(CookieHelper.MemberID, model); result.Message = "基本信息保存成功!"; } catch (Exception ex) { result.Message = "基本信息保存失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + model.MemberID + "基本信息保存失败!", ex); return(View(model)); } } else { result.Message = "表单输入有误,请仔细填写表单!"; result.AddServiceError("表单输入有误,请仔细填写表单!"); } return(View(model)); }
protected bool ValidateUser(User userToValidate, ServiceResult serviceResult) { //Users tied to a FB account will not have a password //When updating users, a password will not be included, thus the UserId condition if (userToValidate.UserId <= 0 && String.IsNullOrEmpty(userToValidate.Password) && userToValidate.FacebookId == null) { serviceResult.AddServiceError("Password", "A password is required"); } if (_repository.Users.Filter(user => user.UserName.Trim().ToLower().Equals(userToValidate.UserName.Trim().ToLower()) && !user.UserId.Equals(userToValidate.UserId)).Count() > 0) { serviceResult.AddServiceError("UserName", "A user with this username already exists."); } if (_repository.Users.Filter(user => user.EmailAddress.Equals(userToValidate.EmailAddress) && !user.UserId.Equals(userToValidate.UserId)).Count() > 0) { serviceResult.AddServiceError("EmailAddress", "This email is already in use by another user."); } //TODO: Swear filter username if (userToValidate.Image != null) { userToValidate.Image = Utilities.ResizeImage(userToValidate.Image, 180, 180); } return(serviceResult.Success); }
public ActionResult Add(OutDoorAdminViewModel model) { ServiceResult result = new ServiceResult(); var AreaCateArray = new List <int>(); var CrowdCateArray = new List <int>(); var IndustryCateArray = new List <int>(); var PurposeCateArray = new List <int>(); //if (!string.IsNullOrEmpty(model.AreaCate)) //{ // AreaCateArray = model.AreaCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.CrowdCate)) //{ // CrowdCateArray = model.CrowdCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.IndustryCate)) //{ // IndustryCateArray = model.IndustryCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} //if (!string.IsNullOrEmpty(model.PurposeCate)) //{ // PurposeCateArray = model.PurposeCate.Split(',').Select(x => Convert.ToInt32(x)).ToList(); //} TempData["Service_Result"] = result; if (!ModelState.IsValid) { result.Message = "表单输入有误,请仔细填写表单!"; result.AddServiceError("表单输入有误,请仔细填写表单!"); } else { try { OutDoorService.Create(model); result.Message = "后台添加户外成功!"; return(RedirectToAction("index")); } catch (Exception ex) { result.Message = "后台添加户外失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("后台用户:" + CookieHelper.MemberID + "添加户外失败!", ex); } } //ViewBag.Data_CrowdCate = Utilities.GetSelectListData(CrowdCateService.GetALL(), x => x.ID, x => x.CateName, CrowdCateArray, false); //ViewBag.Data_IndustryCate = Utilities.GetSelectListData(IndustryCateService.GetALL(), x => x.ID, x => x.CateName, IndustryCateArray, false); //ViewBag.Data_PurposeCate = Utilities.GetSelectListData(PurposeCateService.GetALL(), x => x.ID, x => x.CateName, PurposeCateArray, false); //ViewBag.Data_AreaCate = Utilities.GetSelectListData(AreaCateService.GetALL(), x => x.ID, x => x.CateName, AreaCateArray, false); ViewBag.Data_FormatCode = Utilities.GetSelectListData(FormatCateService.GetALL(), x => x.ID, x => x.CateName, true); ViewBag.Data_PeriodCode = Utilities.GetSelectListData(PeriodCateService.GetALL(), x => x.ID, x => x.CateName, true); //ViewBag.Data_OwnerCode = Utilities.GetSelectListData(OwnerCateService.GetALL(), x => x.ID, x => x.CateName, false); return(View(model)); }
protected bool ValidateCoupon(Coupon couponToValidate, ServiceResult serviceResult) { if (couponToValidate.EndDateTime < couponToValidate.StartDateTime) { serviceResult.AddServiceError("EndDateTime", "The effective end date must be after the effective start date."); } if (couponToValidate.Value <= 0) { serviceResult.AddServiceError("Value", "Value must be positive."); } if (couponToValidate.MaxRegistrantCount <= 0) { serviceResult.AddServiceError("MaxRegistrantCount", "Max registrant count must be positive or empty"); } if (_repository.DiscountItems.Filter(x => x.DiscountItemId != couponToValidate.DiscountItemId && x.Code.ToUpper() == couponToValidate.Code.ToUpper()).Any()) { serviceResult.AddServiceError("Code", "The code you entered is already in use by another discount."); } // does not need to be associated with an event null == all events //if (couponToValidate.CouponType == CouponType.Registration && !couponToValidate.EventId.HasValue) // serviceResult.AddServiceError("EventId", "Registration coupons must be associated to an event."); return(serviceResult.Success); }
public ActionResult Edit(SchemeAddViewModel model) { ViewBag.MenuItem = "scheme-media"; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { var entity = new Scheme(); entity.ID = model.ID; entity.Name = model.Name; entity.Description = model.Description; SchemeService.Update(entity); result.Message = "媒体方案修改成功!"; return(Redirect(Url.Action("index"))); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "媒体方案修改失败!", ex); } } else { result.Message = "表单输入有误!"; result.AddServiceError("表单输入有误!"); } return(View(model)); }
public ActionResult ChangePwd(ChangePasswordViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; ViewBag.MenuItem = "changepwd"; if (ModelState.IsValid) { try { var memberID = Convert.ToInt32(CookieHelper.UID); if (!MemberService.ChangePassword(memberID, model.OldPassword, model.NewPassword)) { result.Message = "旧密码错误!"; result.AddServiceError("旧密码错误"); return(View(model)); } result.Message = "密码修改成功!"; return(RedirectToAction("changepwd")); } catch (Exception ex) { result.Message = "密码修改失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + model.MemberID + "密码修改失败!", ex); } } return(View(model)); }
public ActionResult AddScheme(AddSchemeViewModel model) { ServiceResult result = new ServiceResult(); try { SchemeItem entity = new SchemeItem(); entity.MediaID = model.id; entity.StartTime = Convert.ToDateTime(model.startTime); entity.EndTime = Convert.ToDateTime(model.endTime); entity.Price = Convert.ToDecimal(model.price); entity.PeriodCode = model.periodCode; entity.PeriodCount = model.periodCount; if (string.IsNullOrEmpty(model.Name) && model.schemeId != 0) { entity.SchemeID = model.schemeId; if (SchemeItemService.GetALL().Any(x => x.MediaID == model.id && x.SchemeID == model.schemeId)) { result.AddServiceError("该方案已经包含了此媒体"); result.Message = "该方案已经包含了此媒体!"; } } else { Scheme scheme = new Scheme() { AddTime = DateTime.Now, Name = model.Name, Description = model.Description, LastTime = DateTime.Now, MemberID = CookieHelper.MemberID }; SchemeService.Create(scheme); entity.SchemeID = scheme.ID; } if (result.Success) { SchemeItemService.Create(entity); result.Message = "加入方案成功!"; } } catch (Exception ex) { result.Message = "加入方案失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "加入方案失败!", ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ServiceResult UpdateEventSponsor(EventSponsor sponsor) { var result = new ServiceResult(); try { if (ValidateSponsor(sponsor, result)) { EventSponsor updateSponsor = _repository.EventSponsors.Find(x => x.EventSponsorId == sponsor.EventSponsorId); updateSponsor.SponsorName = sponsor.SponsorName; updateSponsor.Description = sponsor.Description; _repository.EventSponsors.Update(updateSponsor); _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult RemoveEventWave(int eventWaveId) { var result = new ServiceResult(); try { EventWave waveToDelete = _repository.EventWaves.Find(x => x.EventWaveId == eventWaveId); if (CanRemoveEventWave(waveToDelete, result)) { _repository.EventWaves.Delete(waveToDelete); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult UpdateEventWave(EventWave ew) { var result = new ServiceResult(); try { if (ValidateEventWave(ew, result)) { EventWave updateWave = _repository.EventWaves.Find(x => x.EventWaveId == ew.EventWaveId); updateWave.StartTime = ew.StartTime; updateWave.EndTime = ew.EndTime; updateWave.IsActive = ew.IsActive; updateWave.MaxRegistrants = ew.MaxRegistrants; _repository.EventWaves.Update(updateWave); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
private bool ValidateCreateEventDate(EventDate dateToValidate, ServiceResult result) { if (dateToValidate.DateOfEvent.Date < DateTime.Now.Date) { result.AddServiceError("DateOfEvent", "You can not add an event date that is in the past"); } else { if (_repository.EventDates.Find(x => dateToValidate.DateOfEvent == x.DateOfEvent && dateToValidate.EventId == x.EventId) != null) { result.AddServiceError("DateOfEvent", "This date is already attached to this event."); } } return(result.Success); }
public ServiceResult UpdateEventLead(EventLead eventLead) { var result = new ServiceResult(); try { if (ValidateEventLead(eventLead, result)) { EventLead updateLead = _repository.EventLeads.Find(x => x.EventLeadId == eventLead.EventLeadId); updateLead.EventLeadTypeId = eventLead.EventLeadTypeId; updateLead.DisplayText = eventLead.DisplayText; updateLead.EventId = eventLead.EventId.HasValue ? eventLead.EventId : null; updateLead.Title = eventLead.Title; if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult UpdateEventFee(EventFee fee) { var result = new ServiceResult(); try { if (ValidateEventFee(fee, result)) { EventFee updateFee = _repository.EventFees.Find(x => x.PurchaseItemId == fee.PurchaseItemId); updateFee.EffectiveDate = fee.EffectiveDate; updateFee.Cost = fee.Cost; if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult UpdatePassword(int userId, string password) { //TODO: Check password requirements - length, complexity, etc var result = new ServiceResult(); try { var updateUser = _repository.Users.Get(userId); var chc = Crypto.CreateHash(password); updateUser.Password = chc.hash; updateUser.Salt = chc.salt; _repository.Users.Update(updateUser); if (result.Success) { _repository.SaveChanges(); // _repository.Users.LoadProperties(updateUser); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult RemoveEventSponsor(int eventId, string fileName) { var result = new ServiceResult(); try { IQueryable <EventSponsor> sponsorsToDelete = _repository.EventSponsors.Filter(x => x.FileName == fileName && x.EventId == eventId); foreach (EventSponsor sponsorToDelete in sponsorsToDelete) { if (CanRemoveSponsor(sponsorToDelete, result)) { _repository.EventSponsors.Delete(sponsorToDelete); } } _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ActionResult Create(DetailsViewModel model) { var groups = GetForeignData(); ViewBag.Data_GroupID = groups; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { MemberService.Create(model); result.Message = "添加会员信息成功!"; LogHelper.WriteLog("添加会员信息成功"); return RedirectToAction("index"); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加会员信息错误", ex); return View(model); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return View(model); } }
public ActionResult AddMessage(int id, string name, string content) { ServiceResult result = new ServiceResult(); try { var message = new Message() { AddTime = DateTime.Now, SenderID = CookieHelper.MemberID, RecipientID = id, MessageType = (int)MessageType.Member, RecipienterStatus = (int)MessageStatus.Show, Title = name, Content = content }; MessageService.Create(message); result.Message = "留言成功!"; } catch (Exception ex) { result.Message = "留言失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog(CookieHelper.MemberID + "留言失败!", ex); } return(Json(result)); }
public ActionResult EditSchemeMedia(EditSchemeViewModel model) { ServiceResult result = new ServiceResult(); try { var startTime = Convert.ToDateTime(model.startTime); var entity = new SchemeItem() { ID = model.id, PeriodCode = model.periodCode, PeriodCount = model.periodCount, StartTime = startTime, Price = Convert.ToDecimal(model.price), EndTime = startTime.AddDays(model.periodCode * model.periodCount) }; SchemeItemService.Update(entity); } catch (Exception ex) { result.Message = "加入方案失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog(CookieHelper.MemberID + model.id + "加入方案失败", ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ServiceResult CreateTeam(Team team, int registrationId) { ServiceResult result = new ServiceResult(); try { team.Name = team.Name.Trim(); team.DateAdded = DateTime.Now; if (ValidateTeam(team, result)) { team.Code = GenerateTeamCode(team.EventId); _repository.Teams.Create(team); var reg = _repository.Registrations.Find(x => x.RegistrationId == registrationId); reg.Team = team; _repository.Registrations.Update(reg); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(ex.Message); } return(result); }
public ServiceResult RemoveEventDate(int eventDateId) { var result = new ServiceResult(); try { EventDate dateToDelete = _repository.EventDates.Find(x => x.EventDateId == eventDateId); List <int> waveIds = dateToDelete.EventWaves.Select(x => x.EventWaveId).ToList(); foreach (int waveId in waveIds) { EventWave wave = dateToDelete.EventWaves.Single(x => x.EventWaveId == waveId); if (CanRemoveEventWave(wave, result)) { _repository.EventWaves.Delete(wave); } } if (result.Success && CanRemoveEventDate(dateToDelete, result)) { _repository.EventDates.Delete(dateToDelete); _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult UpdateEventDate(EventDate ed) { var result = new ServiceResult(); try { if (ValidateEventDate(ed, result)) { EventDate updateDate = _repository.EventDates.Find(x => x.EventDateId == ed.EventDateId); updateDate.DateOfEvent = ed.DateOfEvent; foreach (EventWave w in updateDate.EventWaves) { w.StartTime = new DateTime(ed.DateOfEvent.Year, ed.DateOfEvent.Month, ed.DateOfEvent.Day, w.StartTime.Hour, w.StartTime.Minute, w.StartTime.Second); w.EndTime = new DateTime(ed.DateOfEvent.Year, ed.DateOfEvent.Month, ed.DateOfEvent.Day, w.EndTime.Hour, w.EndTime.Minute, w.EndTime.Second); } _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult ChangeWave(int registrationId, int eventWaveId) { var result = new ServiceResult(); try { Registration existingReg = _repository.Registrations.Find(x => x.RegistrationId == registrationId); int eventId = existingReg.EventWave.EventDate.EventId; int newEventId = GetEventWaveById(eventWaveId).EventDate.EventId; if (existingReg.TeamId != null && eventId != newEventId) { existingReg.TeamId = null; } existingReg.EventWaveId = eventWaveId; existingReg.DateUpdated = DateTime.Now; if (!_sharedRepository) { _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult GeneratePasswordResetRequestForGoLive(User user) { if (user == null) { throw new ArgumentNullException("user"); } // Get user object var result = new ServiceResult(); try { var byteArray = new byte[128]; // Create new Cryptography object using (var crypto = new RNGCryptoServiceProvider()) { crypto.GetNonZeroBytes(byteArray); user.PasswordResetToken = Convert.ToBase64String(byteArray); user.PasswordResetToken = user.PasswordResetToken.Replace("+", ""); user.PasswordResetRequested = DateTime.Now.AddDays(10); _repository.SaveChanges(); SendPasswordResetForGoLiveEmail(user); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult CreateNewRegistration(Registration r, int?redemtpionId) { var result = new ServiceResult(); try { result = CreateNewRegistration(r); if (result.Success) { //Check to see if the discount id being passed in is a redemption code, if it is, update it. var code = _repository.RedemptionCodes.Find(x => x.DiscountItemId == redemtpionId); if (code != null) { code.GeneratingRegistration.RegistrationStatus = code.RedemptionCodeType == RedemptionCodeType.Transfer ? RegistrationStatus.Transferred : RegistrationStatus.Cancelled; code.ResultingRegistrationId = r.RegistrationId; r.ParentRegistrationId = code.GeneratingRegistrationId; if (!_sharedRepository) { _repository.SaveChanges(); } } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ServiceResult UpdateCoupon(Coupon coupon) { ServiceResult result = new ServiceResult(); try { if (ValidateCoupon(coupon, result)) { Coupon updateCoupon = _repository.Coupons.Find(x => x.DiscountItemId == coupon.DiscountItemId); updateCoupon.Code = coupon.Code; updateCoupon.CouponType = coupon.CouponType; updateCoupon.DiscountType = coupon.DiscountType; updateCoupon.Description = coupon.Description; updateCoupon.EndDateTime = coupon.EndDateTime; updateCoupon.IsActive = coupon.IsActive; updateCoupon.IsReusable = coupon.IsReusable; updateCoupon.MaxRegistrantCount = coupon.MaxRegistrantCount; updateCoupon.StartDateTime = coupon.StartDateTime; updateCoupon.EventId = coupon.EventId; updateCoupon.Value = coupon.Value; if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
public ActionResult FavoriteDelete(string ids) { ServiceResult result = new ServiceResult(); try { var idsList = Utilities.GetIdList(ids); foreach (var id in idsList) { var model = FavoriteService.Find(id); FavoriteService.Delete(model); } result.Message = "删除收藏成功!"; } catch (Exception ex) { result.Message = "删除收藏失败!"; result.AddServiceError(Utilities.GetInnerMostException(ex)); LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "删除收藏失败!", ex); } return Json(result); }
public ActionResult PayCz(int ApplyMoney, string txtMoney) { ViewBag.MenuItem = "gztvip-paycz"; ServiceResult result = new ServiceResult(); if (string.IsNullOrEmpty(txtMoney)) { txtMoney = "0"; } var intMoney = Convert.ToInt32(txtMoney); var vip = member_VIPService.GetMemberVIP(CookieHelper.MemberID, true); ViewBag.VIP = vip; try { PayList orderItem = new PayList(); switch (ApplyMoney) { case 200: case 500: case 1000: if (vip != null && vip.EndTime.CompareTo(DateTime.Now) > 0) { if (vip.VipLevel == (int)ServerType.NomarlVIPServer) { orderItem.VMoney = ApplyMoney / 10; } else if (vip.VipLevel == (int)ServerType.SuperVIPServer) { orderItem.VMoney = ApplyMoney / 5; } } else { orderItem.VMoney = 0; } orderItem.Money = ApplyMoney; break; case 600: orderItem.Money = intMoney; if (vip != null && vip.EndTime.CompareTo(DateTime.Now) > 0) { if (vip.VipLevel == (int)ServerType.NomarlVIPServer) { orderItem.VMoney = intMoney / 10; } else if (vip.VipLevel == (int)ServerType.SuperVIPServer) { orderItem.VMoney = intMoney / 5; } } else { orderItem.VMoney = 0; } break; default: return Content("<script>alert('您提交的表单有误!');window.top.location='" + Url.Action("paycz") + "';</script>"); } orderItem.Pay_No = Guid.NewGuid(); orderItem.MemberID = CookieHelper.MemberID; orderItem.Mode = "GZBCZ"; orderItem.ProductType = "GZBCZ"; orderItem.Status = Pay_State.Applying.ToString(); orderItem.AddTime = DateTime.Now; orderItem.AddIP = HttpHelper.IP; payListService.CreateOrder(orderItem); result = member_VIPService.PayMoney(CookieHelper.MemberID, orderItem); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } var money = member_MoneyService.GetMemberMoney(CookieHelper.MemberID); ViewBag.Money = money; result.Message = "充值" + (result.Success ? "成功!" : "失败!"); TempData["Service_Result"] = result; if (result.Success) { return RedirectToAction("OpenOK"); } return View(vip); }
public ActionResult TopSet(PayTopViewModel model) { ViewBag.MenuItem = "gztvip-paytop"; ServiceResult result = new ServiceResult(); var server = serverItemService.Find(model.TopID); var money = member_MoneyService.GetMemberMoney(CookieHelper.MemberID); var dayCount = model.TopTime.Split(',').Length; var totalPrice = Convert.ToInt32((server.Price * dayCount * model.Discount / 10)); if (money < totalPrice) { result.AddServiceError("您当前剩余广知币不足已支付。当前" + money + "个,支付需要" + totalPrice + "个"); } ViewBag.Money = money; List<TopLimitModel> topLimit = sliderImgService.GetTopSourceLimit(30); for (var i = 0; i < model.TopTime.Split(',').Length; i++) { var topitem = model.TopTime.Split(',')[i]; if (topLimit.Any(x => x.Time.Equals(topLimit))) { var limit = topLimit.Single(x => x.Time.Equals(topLimit)); if (limit.Count >= 8) { result.AddServiceError(topitem + "的置顶已达到最大数,请选择其他日期。"); } } } if (result.Success) { List<SliderImg> payModel = new List<SliderImg>(); for (var i = 0; i < model.TopTime.Split(',').Length; i++) { var topTime = Convert.ToDateTime(model.TopTime.Split(',')[i]); SliderImg payItem = new SliderImg() { MemberID = CookieHelper.MemberID, AddTime = DateTime.Now, TopTime = topTime, ImgUrl = model.ImgUrl, LinkUrl = model.LinkUrl, ProvinceCode = (int)ProvinceName.quanguo, Status = (int)SliderImgStatus.User, Title = model.Name }; payModel.Add(payItem); } var excuteresult = sliderImgService.PayTopSliderImg(payModel, totalPrice); if (!excuteresult.Success) { result.AddServiceError("置顶失败!"); } } else { #region GetTopMediaSource List<CustomSelectListItem> select = new List<CustomSelectListItem>(); var startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1); for (var i = 0; i < 30; i++) { var day = startTime.AddDays(i); var dayString = day.ToString("yyyy-MM-dd"); if (topLimit.Any(x => x.Time.Equals(dayString))) { var limit = topLimit.Single(x => x.Time.Equals(dayString)); var limitStr = Convert.ToDateTime(limit.Time).ToString("MM-dd"); if (limit.Count >= 8) { select.Add(new CustomSelectListItem() { Disabled = true, Text = limitStr + " (已售)", Value = limit.Time }); } else { select.Add(new CustomSelectListItem() { Text = limitStr, Value = limit.Time }); } } else { select.Add(new CustomSelectListItem() { Text = day.ToString("MM-dd"), Value = dayString }); } } ViewBag.Data_TopTime = select; #endregion ViewBag.CheckErr = result; } result.Message = "置顶" + (result.Success ? "成功!" : "失败!"); TempData["Service_Result"] = result; if (result.Success) { return RedirectToAction("OpenOK"); } var vip = member_VIPService.GetMemberVIP(CookieHelper.MemberID, true); ViewBag.VIP = vip; return View(model); }
public ActionResult Open(int ID, int Price) { ViewBag.MenuItem = "gztvip-index"; ServiceResult result = new ServiceResult(); var server = serverItemService.Find(ID); try { if (server == null) { return Content("<script>alert('您提交的表单有误!');window.top.location='" + Url.Action("Index") + "';</script>"); } PayList orderItem = new PayList(); orderItem.Pay_No = Guid.NewGuid(); orderItem.MemberID = CookieHelper.MemberID; orderItem.Money = server.Price; orderItem.ServerID = ID; orderItem.Mode = "VIPTest"; orderItem.ProductType = UIHelper.ServerTypeList.Single(x => x.Value == server.ServerType.ToString()).Text; orderItem.Status = Pay_State.Applying.ToString(); orderItem.AddTime = DateTime.Now; orderItem.AddIP = HttpHelper.IP; payListService.CreateOrder(orderItem); result = member_VIPService.PayVIP(CookieHelper.MemberID, server, orderItem); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } var vip = member_VIPService.GetMemberVIP(CookieHelper.MemberID, true); var money = member_MoneyService.GetMemberMoney(CookieHelper.MemberID); ViewBag.Money = money; result.Message = "VIP开通" + (result.Success ? "成功!" : "失败!"); TempData["Service_Result"] = result; ViewBag.Server = server; if (result.Success) { return RedirectToAction("openok"); } return View(vip); }
public ActionResult TopMedia(PayTopMeidaViewModel model) { ViewBag.MenuItem = "gztvip-paytop"; ServiceResult result = new ServiceResult(); var server = serverItemService.Find(model.TopID); var money = member_MoneyService.GetMemberMoney(CookieHelper.MemberID); var dayCount = model.TopTime.Split(',').Length; var totalPrice = Convert.ToInt32((server.Price * dayCount * model.Discount / 10)); if (money < totalPrice) { result.AddServiceError("您当前剩余广知币不足已支付。当前" + money + "个,支付需要" + totalPrice + "个"); } ViewBag.Money = money; List<TopLimitModel> topLimit = topMediaService.GetTopSourceLimit(30); for (var i = 0; i < model.TopTime.Split(',').Length; i++) { var topitem = model.TopTime.Split(',')[i]; if (topLimit.Any(x => x.Time.Equals(topLimit))) { var limit = topLimit.Single(x => x.Time.Equals(topLimit)); if (limit.Count >= 8) { result.AddServiceError(topitem + "的置顶已达到最大数,请选择其他日期。"); } } } if (result.Success) { List<TopMedia> payModel = new List<TopMedia>(); var media = outDoorService.IncludeCategoryFind(model.MediaID.Value); for (var i = 0; i < model.TopTime.Split(',').Length; i++) { var topTime = Convert.ToDateTime(model.TopTime.Split(',')[i]); TopMedia payItem = new TopMedia() { MediaID = model.MediaID.Value, TopTime = topTime, MemberID = CookieHelper.MemberID }; payItem.IsQuanGuo = server.IsQuanGuo; payItem.IsByCategory = server.IsByCategory; payItem.IsByChildCategory = server.IsByChildCategory; payItem.ProvinceCode = media.Area.PCategory.ID; payItem.CategoryCode = media.MeidaCode; payItem.PCategoryCode = media.OutDoorMediaCate.PCategory.ID; payModel.Add(payItem); } var excuteresult = topMediaService.PayTopMedia(payModel, totalPrice); if (!excuteresult.Success) { result.AddServiceError("置顶失败!"); } } else { ViewBag.CheckErr = result; } result.Message = "置顶" + (result.Success ? "成功!" : "失败!"); TempData["Service_Result"] = result; if (result.Success) { return RedirectToAction("OpenOK"); } var vip = member_VIPService.GetMemberVIP(CookieHelper.MemberID, true); ViewBag.VIP = vip; ViewBag.Server = server; return View(model); }
public ActionResult Add(SchemeAddViewModel model) { ViewBag.MenuItem = "scheme-add"; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { var memberID = Convert.ToInt32(CookieHelper.UID); Member_Scheme ms = new Member_Scheme() { Name = model.Name, Description = model.Description, MemberID = memberID, AddTime = DateTime.Now, LastTime = DateTime.Now, }; member_SchemeService.Create(ms); result.Message = "媒体方案保存成功!"; return Redirect(Url.Action("index")); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); } } else { result.Message = "表单输入有误!"; result.AddServiceError("表单输入有误!"); } return View(model); }
public ActionResult SchemeMedia_Delete(int id) { ServiceResult result = new ServiceResult(); try { var model = scheme_MediaService.Find(id); scheme_MediaService.Delete(model); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } result.Message = "删除收藏" + (result.Success ? "成功!" : "失败!"); return Json(result); }
public ActionResult Edit(SchemeAddViewModel model) { ViewBag.MenuItem = "scheme-index"; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { var scheme = new Member_Scheme(); scheme.ID = model.ID; scheme.Name = model.Name; scheme.Description = model.Description; member_SchemeService.Update(scheme); result.Message = "媒体方案保存成功!"; return Redirect(Url.Action("index")); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); } } else { result.Message = "表单输入有误!"; result.AddServiceError("表单输入有误!"); } return View(model); }