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 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())); }
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); }
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 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 ServiceResult RemoveEventLead(int eventLeadId) { var result = new ServiceResult(); try { EventLead leadToDelete = _repository.EventLeads.Find(x => x.EventLeadId == eventLeadId); if (CanRemoveEventLead(leadToDelete, result)) { _repository.EventLeads.Delete(leadToDelete); if (!_sharedRepository) { _repository.SaveChanges(); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return(result); }
private bool ValidateEventLead(EventLead eventLead, ServiceResult result) { return(result.Success); }
private bool CanRemoveEventLead(EventLead eventLead, ServiceResult result) { return(result.Success); }