public async Task <IActionResult> PostEventConfirmation([FromBody] EventConfirmation eventConfirmation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_context.EventConfirmations.Any(e => e.EventId == eventConfirmation.EventId && e.UserId == eventConfirmation.UserId)) { apiError.Error = new Error { Code = Convert.ToInt16(StatusCodes.Status422UnprocessableEntity).ToString(), Message = "Esse evento já esta confirmado para esse usuário." }; return(StatusCode(StatusCodes.Status422UnprocessableEntity, apiError)); } if (eventConfirmation.EventId != 0) { eventConfirmation.@event = null; } if (eventConfirmation.UserId != 0) { eventConfirmation.User = null; } _context.EventConfirmations.Add(eventConfirmation); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEventConfirmation", new { id = eventConfirmation.Id }, eventConfirmation)); }
public async Task <IActionResult> PutEventConfirmation([FromRoute] int id, [FromBody] EventConfirmation eventConfirmation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eventConfirmation.Id) { return(BadRequest()); } _context.Entry(eventConfirmation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventConfirmationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected void ProcessCreateCustomerResponse(ApiResponse[] responses, EventConfirmation confirmation) { var createCustomerResponse = GetExigoApiResponse(typeof(CreateCustomerResponse), responses) as CreateCustomerResponse; if (ProcessExigoApiResponse(createCustomerResponse, confirmation)) { confirmation.CustomerID = createCustomerResponse.CustomerID; return; } }
private void OkButton_Click(object sender, RoutedEventArgs e) { CloseWindow(); EventConfirmation?.Invoke(); }
protected void ProcessUpdatePartyCustomerResponse(TransactionalResponse result, EventBooking eventBooking, EventConfirmation confirmation) { try { if (IsSuccess(result) && result.TransactionResponses != null && result.TransactionResponses.Length != 0) { confirmation.Result.Status = Status.Success; var responses = result.TransactionResponses; ProcessExigoApiResponse(typeof(UpdateCustomerResponse), responses, confirmation); ProcessExigoApiResponse(typeof(SetCustomerSiteResponse), responses, confirmation); ProcessExigoApiResponse(typeof(UpdateCustomerExtendedResponse), responses, confirmation); } else { confirmation.Result.Status = Status.Failure; ProcessWarnings(result, confirmation); ProcessErrors(result, confirmation); } } catch (Exception ex) { if (Status.Success.Equals(confirmation.Result.Status)) { confirmation.Result.Errors.Add("Your event was updated but an unexpected error was encountered: " + ex.Message); } else { confirmation.Result.Errors.Add("There was an unexpected error while updateing your event: " + ex.Message); } } }
EventConfirmation IEventService.EditEvent(Common.ModelsEx.Event.EventBooking eventBooking) { var confirmation = new EventConfirmation(); TransactionalResponse result = null; try { var requests = new List <ApiRequest>(); // Need to create customer if new party customer if (eventBooking.Customer.CustomerID != 0) { // TODO: gwb:20150111 - Need clarification which fields can be updated for a party // Right now, updating party location var updateCustomerRequest = new UpdateCustomerRequest { CustomerID = eventBooking.Customer.CustomerID, FirstName = eventBooking.Customer.FirstName, LastName = eventBooking.Customer.LastName, MainAddress1 = eventBooking.Customer.MainAddress.Address1, MainAddress2 = eventBooking.Customer.MainAddress.Address2, MainCity = eventBooking.Customer.MainAddress.City, MainState = eventBooking.Customer.MainAddress.State, MainZip = eventBooking.Customer.MainAddress.Zip, MainCountry = eventBooking.Customer.MainAddress.Country }; requests.Add(updateCustomerRequest); } else { throw new ApplicationException("Cannot call EditEvent for a new event. Call CreateEvent instead."); } var setCustomerSiteRequest = new SetCustomerSiteRequest(eventBooking.CustomerSite); requests.Add(setCustomerSiteRequest); var getCustomerExtendedRequest = new GetCustomerExtendedRequest() { CustomerID = eventBooking.Customer.CustomerID, ExtendedGroupID = (int)CustomerExtendedGroup.PartyDetails // Party Extended Fields }; var getCustomerExtendedResponse = Exigo.GetCustomerExtendedDetails(eventBooking.Customer.CustomerID, (int)CustomerExtendedGroup.PartyDetails).FirstOrDefault(); var updateCustomerExtendedRequest = new UpdateCustomerExtendedRequest() { CustomerExtendedID = getCustomerExtendedResponse.CustomerExtendedDetailID, CustomerID = eventBooking.Customer.CustomerID, ExtendedGroupID = (int)CustomerExtendedGroup.PartyDetails, // Party Extended Fields Field2 = eventBooking.ActualStartDate.ToString(), Field3 = eventBooking.CloseDate.ToString(), Field4 = eventBooking.LockoutDate.ToString(), Field12 = eventBooking.PartyDate.ToString(), Field13 = eventBooking.PartyStartTime, Field14 = eventBooking.PartyEndTime, Field15 = eventBooking.TimeZone }; requests.Add(updateCustomerExtendedRequest); result = Api.ProcessTransaction(new TransactionalRequest { TransactionRequests = requests.ToArray() }); } catch (Exception ex) { if (Status.Success.Equals(confirmation.Result.Status)) { confirmation.Result.Errors.Add("Your event was updated but an unexpected error was encountered: " + ex.Message); } else { confirmation.Result.Errors.Add("There was an unexpected error while updating your event: " + ex.Message); } return(confirmation); } try { using (var context = Exigo.Sql()) { string sqlProcedure = string.Format("UpdateEvent {0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}'", eventBooking.Customer.CustomerID, eventBooking.Customer.FirstName, eventBooking.ActualStartDate.ToString(CultureInfo.InvariantCulture), eventBooking.CloseDate.ToString(CultureInfo.InvariantCulture), eventBooking.LockoutDate.ToString(CultureInfo.InvariantCulture), eventBooking.PartyStartTime, eventBooking.PartyEndTime, eventBooking.TimeZone, eventBooking.CustomerSite.WebAlias); bool eventUpdated = context.Query <bool>(sqlProcedure).FirstOrDefault(); } } catch (Exception EX) { } ProcessUpdatePartyCustomerResponse(result, eventBooking, confirmation); return(confirmation); }
EventConfirmation IEventService.CreateEvent(Common.ModelsEx.Event.EventBooking eventBooking) { var confirmation = new EventConfirmation(); TransactionalResponse result = null; try { var requests = new List <ApiRequest>(); // Need to create customer if new party customer if (eventBooking.Customer.CustomerID == 0) { // TODO: gwb:20150111 - What is the default warehouse for a party customer? var createCustomerRequest = new CreateCustomerRequest(eventBooking.Customer); requests.Add(createCustomerRequest); } else { throw new ApplicationException("Cannot call CreateEvent for an existing event. Call EditEvent instead."); } var setCustomerSiteRequest = new SetCustomerSiteRequest(eventBooking.CustomerSite); requests.Add(setCustomerSiteRequest); var hostSpecial = RewardService.GetHostSpecialReward(eventBooking.ActualStartDate); var createCustomerExtendedRequest = new CreateCustomerExtendedRequest() { CustomerID = eventBooking.Customer.CustomerID, ExtendedGroupID = (int)CustomerExtendedGroup.PartyDetails, // Party Extended Fields Field1 = eventBooking.StartDate.ToString(CultureInfo.InvariantCulture), Field2 = eventBooking.ActualStartDate.ToString(CultureInfo.InvariantCulture), Field3 = eventBooking.CloseDate.ToString(CultureInfo.InvariantCulture), Field4 = eventBooking.LockoutDate.ToString(CultureInfo.InvariantCulture), Field5 = eventBooking.CreatorCustomerID.ToString(), Field6 = eventBooking.HostCustomerID.ToString(), Field8 = hostSpecial.ItemCode, Field9 = hostSpecial.DiscountAmount.ToString(CultureInfo.InvariantCulture), Field10 = string.Empty, // Reward Not Redeemed Field11 = hostSpecial.SalesThreshold.ToString(CultureInfo.InvariantCulture), Field12 = eventBooking.PartyDate.ToString(CultureInfo.InvariantCulture), Field13 = eventBooking.PartyStartTime, Field14 = eventBooking.PartyEndTime, Field15 = eventBooking.TimeZone }; requests.Add(createCustomerExtendedRequest); result = Api.ProcessTransaction(new TransactionalRequest { TransactionRequests = requests.ToArray() }); } catch (Exception ex) { if (Status.Success.Equals(confirmation.Result.Status)) { confirmation.Result.Errors.Add("Your event was created but an unexpected error was encountered: " + ex.Message); } else { confirmation.Result.Errors.Add("There was an unexpected error while creating your event: " + ex.Message); } return(confirmation); } ProcessCreatePartyCustomerResponse(result, eventBooking, confirmation); // save new event entry into database to overcome delay try { using (var context = Exigo.Sql()) { string sqlProcedure = string.Format("InsertNewCreatedEvent {0},{1},'{2}','{3}','{4}','{5}','{6}'", confirmation.CustomerID, eventBooking.CreatorCustomerID, eventBooking.Customer.FirstName, eventBooking.ActualStartDate.ToString(CultureInfo.InvariantCulture), eventBooking.StartDate.ToString(CultureInfo.InvariantCulture), eventBooking.CloseDate.ToString(CultureInfo.InvariantCulture), eventBooking.LockoutDate.ToString(CultureInfo.InvariantCulture)); bool eventinserted = context.Query <bool>(sqlProcedure).FirstOrDefault(); } } catch (Exception EX) { } return(confirmation); }