Exemplo n.º 1
0
        public async Task<IHttpActionResult> PostEvent(Event eventModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            eventModel.PageContent.LastModified = DateTime.Now;
            eventModel.PageContent.LastModifiedBy = User.Identity.Name;
            

            await repository.AddAsync(eventModel);

            return CreatedAtRoute("DefaultApi", new { id = eventModel.EventID }, eventModel);
        }
Exemplo n.º 2
0
        // PUT api/Events/5
        public async Task<IHttpActionResult> PutEvent(int id, Event eventModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != eventModel.EventID)
            {
                return BadRequest();
            }
            eventModel.PageContent.LastModified = DateTime.Now;
            eventModel.PageContent.LastModifiedBy = User.Identity.Name;

            await repository.UpdateAsync(eventModel, eventModel.EventID);

            return StatusCode(HttpStatusCode.NoContent);
        }
 private bool IsPublicallyOpen(Event evt)
 {
     return !evt.ForceDisableRegistration || evt.DisablePublicRegistration >= cstTime;
 }
 private bool CanAccessRegistration(Event evt)
 {
     return IsPublicallyOpen(evt) || User.IsInRole("Cashier");
 }
 private string GetDisabledMessage(Event evt)
 {
     return string.IsNullOrEmpty(evt.RegistrationDisabledMessage) ? "This event is not currently open for registration." : evt.RegistrationDisabledMessage;
 }