public IActionResult Get() { StringValues hearderValues; var firstValue = string.Empty; if (Request.Headers.TryGetValue("id", out hearderValues)) { firstValue = hearderValues.FirstOrDefault(); } long id = Convert.ToInt64(firstValue); var item = _repository.Find(id); if (item == null || item.UserId == null) { return(NotFound()); } User SelectedUser = new Models.User(); SelectedUser = _userRepository.Find(item.UserId); SelectedUser.Interactions = null; SelectedUser.Orders = null; SelectedUser.Vouchers = null; item.User = SelectedUser; // Unset variables that are unused SelectedUser = null; return(new ObjectResult(item)); }
public IActionResult DeleteVoucher([FromRoute] long id) { Voucher fin = Vou_repo.Find(id); if (fin == null) { return(NotFound()); } else if (fin.IsFinal == true) { return(BadRequest("Can't delete posted vouchers")); } VouDetail_repo.DeleteRange(VouDetail_repo.GetList(a => a.VoucherId == fin.VoucherId)); Vou_repo.Delete(fin); return(Ok()); }