public ServiceResult UpdateEventLead(EventLead eventLead) { var result = new ServiceResult(); try { if (ValidateEventLead(eventLead, result)) { var updateEventLead = _repository.EventLeads.Find(x => x.EventLeadId == eventLead.EventLeadId); updateEventLead.EventLeadTypeId = eventLead.EventLeadTypeId; updateEventLead.DisplayText = eventLead.DisplayText; updateEventLead.Title = eventLead.Title; if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateEventLead(EventLead eventLead) { var result = new ServiceResult(); try { if (ValidateEventLead(eventLead, result)) { _repository.EventLeads.Create(eventLead); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ActionResult Ajax_CreateEventLead([DataSourceRequest] DataSourceRequest request, vmAdmin_EventLeadItem eventLeadView) { EventLead eventLead = null; if (ModelState.IsValid) { eventLead = new EventLead { DisplayText = eventLeadView.DisplayText, EventId = null, EventLeadId = eventLeadView.EventLeadId, EventLeadTypeId = eventLeadView.EventLeadTypeId, Title = eventLeadView.Title, }; ServiceResult result = _eventLeadService.CreateEventLead(eventLead); if (!result.Success) Utilities.AddModelStateErrors(ModelState, result.GetServiceErrors()); } return Json(new[] { eventLead }.ToDataSourceResult(request, ModelState)); }
public ActionResult Ajax_UpdateEventLead([DataSourceRequest] DataSourceRequest request, vmAdmin_EventLeadItem eventLeadView, int masterEventId) { if (ModelState.IsValid) { if (eventLeadView.IsGlobal == 0) eventLeadView.EventId = masterEventId; else eventLeadView.EventId = null; EventLead eventLead = new EventLead { DisplayText = eventLeadView.DisplayText, EventId = eventLeadView.EventId, EventLeadId = eventLeadView.EventLeadId, EventLeadTypeId = eventLeadView.EventLeadTypeId, Title = eventLeadView.Title }; ServiceResult result = _eventService.UpdateEventLead(eventLead); if (!result.Success) Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors()); } return Json(ModelState.ToDataSourceResult()); }
private bool ValidateEventLead(EventLead eventLead, ServiceResult result) { return result.Success; }
private bool CanRemoveEventLead(EventLead eventLead, ServiceResult result) { return result.Success; }
protected bool ValidateEventLead(EventLead eventLeadToValidate, ServiceResult serviceResult) { //if (couponToValidate.EndDateTime < couponToValidate.StartDateTime) //{ // serviceResult.AddServiceError("EndDateTime", // "The effective end date must be after the effective start date."); //} //foreach (Coupon c in existingCoupons) //{ // if (c.IsActive && // ( // (c.EndDateTime != null && c.EndDateTime > couponToValidate.StartDateTime && // c.StartDateTime < couponToValidate.EndDateTime) || // (c.EndDateTime == null && c.StartDateTime < couponToValidate.EndDateTime) || // (couponToValidate.EndDateTime != null && c.StartDateTime < couponToValidate.EndDateTime && // couponToValidate.StartDateTime < c.EndDateTime) || // (couponToValidate.EndDateTime == null && c.EndDateTime > couponToValidate.StartDateTime) || // (couponToValidate.EndDateTime == null && c.EndDateTime == null) // ) // ) // { // serviceResult.AddServiceError("Code", // "There is already an active coupon with the same code in effect during the selected effective date range."); // } //} return serviceResult.Success; }