Пример #1
0
        public IActionResult Index(EventDateDto eventDateDto)
        {
            EventDate eventDate = _mapper.Map <EventDate>(eventDateDto);

            ViewBag.date = eventDate.Date.ToShortDateString();
            return(View());
        }
Пример #2
0
        public async Task <IActionResult> CreateEvent([FromBody] EventDateDto eventDateDto)
        {
            // TODO Add validation that the dates are in valid format and unique
            var eventIdentity = await Events.CreateEventAsync(eventDateDto.ToEventEntity()).ConfigureAwait(false);

            return(CreatedAtAction(
                       nameof(CreateEvent),
                       new { id = eventIdentity }));
        }
Пример #3
0
 public static EventDate ToEntity(this EventDateDto dto)
 {
     return(new EventDate
     {
         Id = dto.Id,
         Beginning = dto.Beginning,
         Ending = dto.Ending,
         AllDay = dto.AllDay
     });
 }
Пример #4
0
 public static EventEntity ToEventEntity(this EventDateDto dto)
 {
     return(dto == null
         ? null
         : new EventEntity
     {
         Name = dto.Name,
         DateEntities = dto.Dates.Select(d => new DateEntity {
             Date = d
         }).ToList()
     });
 }
Пример #5
0
        /// <summary>
        /// Extracts the specified message content.
        /// </summary>
        /// <param name="messageContent">Content of the message.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Value cannot be null or whitespace. - messageContent</exception>
        // TODO: This method only extracts a single Expense object. Nice to have would be to expand and extract multiple Expenses.
        public Expense Extract(string messageContent)
        {
            if (string.IsNullOrWhiteSpace(messageContent))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(messageContent));
            }

            ValidateMessageContent(messageContent);

            ExpenseDto     expense     = ExtractAndDeserializeExpenseXmlElement(messageContent);
            VendorDto      vendor      = ExtractAndDeserializeXmlElement <VendorDto>(messageContent, ExpenseConstants.Vendor);
            DescriptionDto description = ExtractAndDeserializeXmlElement <DescriptionDto>(messageContent, ExpenseConstants.Description);
            EventDateDto   eventDate   = ExtractAndDeserializeXmlElement <EventDateDto>(messageContent, ExpenseConstants.Date);

            return(ExpenseMapper.Map(expense, vendor, description, eventDate));
        }
Пример #6
0
        /// <summary>
        /// Initializes an <see cref="Expense"/> <see cref="object"/>.
        /// </summary>
        /// <param name="expenseDto">The expense dto.</param>
        /// <param name="vendorDto">The vendor dto.</param>
        /// <param name="descriptionDto">The description dto.</param>
        /// <param name="eventDateDto">The event date dto.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">expenseDto</exception>
        public static Expense Map(ExpenseDto expenseDto, VendorDto vendorDto, DescriptionDto descriptionDto, EventDateDto eventDateDto)
        {
            if (expenseDto == null)
            {
                throw new ArgumentNullException(nameof(expenseDto));
            }

            return(new Expense(
                       expenseDto.Expense.CostCentre ?? string.Empty,
                       expenseDto.Expense.Total,
                       vendorDto?.Vendor ?? string.Empty,
                       descriptionDto?.Description ?? string.Empty,
                       eventDateDto?.Date ?? string.Empty));
        }