public int Create(VacationBindingModel bindingModel) { _context.Vacations.Add(VacationAdapter.ToModel(bindingModel)); _context.SaveChanges(); Event createdEvent = _context.Vacations.OrderByDescending(t => t.EventId).Take(1).FirstOrDefault(); return(createdEvent != null ? createdEvent.EventId : 0); }
public IActionResult Update([FromBody] VacationBindingModel vacationBindingModel) { if (vacationBindingModel != null) { if (_vacationService.Update(VacationAdapter.ToModel(vacationBindingModel)) != 0) { return(Ok(vacationBindingModel)); } else { return(BadRequest(vacationBindingModel)); } } else { return(BadRequest()); } }
public IEnumerable <VacationViewModel> GetAllVacation(int?Id) { if (Id.HasValue && Id == -1) { var Vacations = _vacationService.GetAllVacations(); if (Vacations != null) { return(VacationAdapter.ToViewModel(Vacations)); } else { return(null); } } else { return(VacationAdapter.ToViewModel(_vacationService.GetEmployeeVacations((int)Id))); } //return Ok(new List<VacationViewModel> { new VacationViewModel() { Id = 3, Start = new DateTime(2017,7,19, 7, 30, 0, DateTimeKind.Utc), End = new DateTime(2017, 7, 19, 12, 30, 0, DateTimeKind.Utc), //OwnerId = 1, IsAllDay = false, Title= "asdadfdsfasd", Description = "ok hello ae"} }); }